[英]Laravel Mail attach binary data
Is there any way to attach a binary data as a file? 有什么办法可以将二进制数据作为文件附加吗?
\Mail::send('test', [], function ($message) {
$message->to('xxxxxx.@xx.com', 'X X')->subject('TEST');
$message->attach($file_binary_data);
});
I have checked this, but email didn't send. 我已经检查过了,但是没有发送电子邮件。 Gave only a blank page with no errors. 只给空白页没有错误。
1, The Mail API based drivers such as Mailgun and Mandrill are often simpler and faster than SMTP servers. 1,基于Mail API的驱动程序(例如Mailgun和Mandrill)通常比SMTP服务器更简单,更快。 You should register a mailgun or mandrill account firstly, or use your mail smtp (You can get the smtp info in your email settings) 您应该首先注册一个mailgun或mandrill帐户,或者使用您的邮件smtp(您可以在电子邮件设置中获取smtp信息)
2, the 'test' view file must exist in your 'resources/views' directory. 2,“测试”视图文件必须存在于“资源/视图”目录中。
3, $file_binary_data must exist in your local file system. 3,$ file_binary_data必须存在于本地文件系统中。
Use attachData method: 使用attachData方法:
\Mail::send('test', [], function ($message) {
$message->to('xxxxxx.@xx.com', 'X X')->subject('TEST');
//$message->attach($file_binary_data);
$message->attachData($file_binary_data, 'my-file-name.pdf', []);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.