Sending a string attachment using Mailgun

2019-08-07 15:11发布

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条回答
Lonely孤独者°
2楼-- · 2019-08-07 15:18
$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/

查看更多
登录 后发表回答