Sending a string attachment using Mailgun

大城市里の小女人 提交于 2019-12-11 09:13:45

问题


Is it possible to send an attachment as a string using Mailgun - i.e. similar to the way this can be done in PHPMailer, using AddStringAttachment().

The Mailgun documentation seems to only relate to attaching files. I found this article, but I'm not sure what language the code is written in and don't understand how I could adapt to php.


回答1:


$mg = new Mailgun('mailgun-api-key');
$msg = $mg->MessageBuilder();
$msg->setFromAddress($from);
$msg->setSubject($subject);
$msg->setTextBody($textBody);
$files['attachment'] = array();
$files['attachment'][] = '/var/www/somefile.php';
$mg->post("{$domain}/messages", $msg->getMessage(), $files);

See this link: https://pmellor.wordpress.com/2013/12/11/adding-attachments-to-email-using-the-mailgun-com-php-api/



来源:https://stackoverflow.com/questions/26781940/sending-a-string-attachment-using-mailgun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!