【问题标题】:Is there a way to add a button to attach file to email?有没有办法添加一个按钮来将文件附加到电子邮件?
【发布时间】:2016-08-17 19:46:32
【问题描述】:

在我的情况下,我必须在文件列表中添加电子邮件按钮,但在此之前我必须先签名以便可以查看文件,单击文件时此电子邮件按钮将自动以附件的形式出现发送邮件。在这种情况下,是否可以不必先下载文件,然后将文件作为附件浏览?

【问题讨论】:

  • 问题不太清楚
  • 你想添加一个附加文件的邮件按钮?
  • @AniMenon 是的,该按钮位于每个列表文件上。例如,有一个名为“office.pdf”的文件和上面的邮件按钮,如果我点击它,文件将作为附件附加。有可能吗?

标签: php laravel laravel-5.2 email-attachments email


【解决方案1】:

基础版(使用php):

$email = new PHPMailer();
$email->From      = 'you@example.com';
$email->FromName  = 'Your Name';
$email->Subject   = 'Message Subject';
$email->Body      = $bodytext;
$email->AddAddress( 'destinationaddress@example.com' );
$file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
$email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
return $email->Send();

参考:Send attachments with PHP Mail()?

使用 laravel 5.0:

Mail::send('emails.welcome', $data, function($message)
{
    $message->from('us@example.com', 'Laravel');

    $message->to('foo@example.com')->cc('bar@example.com');

    $message->attach($pathToFile);
});

参考:Laravel mail

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    • 2015-07-09
    • 2015-03-04
    相关资源
    最近更新 更多