我需要使用Mailgun将一些文件附加到电子邮件中 . 实际上我通过ajax将所有数据(从,到,主题......)发送到php脚本 . 对于上传文件,我使用JQuery.fileupload.js,将文件上传到服务器并给我回名称和URL如果它 .

这里有一个简单的Mailgun请求:

$result = $mgClient->sendMessage($domain, array(
'from'    => 'Excited User <cm.carlo.martini@gmail.com>',
'to'      => 'foo@example.com',
'cc'      => 'baz@example.com',
'bcc'     => 'bar@example.com',
'subject' => 'Hello',
'text'    => 'Testing some Mailgun awesomness!',
'html'    => '<html>HTML version of the body</html>'), array(
'attachment' => array('@/path/to/file.txt', '@/path/to/file.txt')));

我试图将文件路径添加到“附件”数组但不起作用 . 如何使用他们的网址发送这些文件?可能是因为'multipart / form-data'......