0

在我的情況下,我必須在文件列表中添加電子郵件按鈕,但在它之前,我必須先簽名以便可以查看該文件,單擊該電子郵件按鈕時該文件將在發送時自動以附件形式發送郵件。在這種情況下,可以不必先下載文件,然後以附件瀏覽文件?有沒有辦法添加一個按鈕來附加文件到電子郵件?

+1

問題不是很清楚 – haakym

+0

你想添加一個附加文件的郵件到按鈕? –

+0

@AniMenon是的,按鈕是在每個列表文件。例如,有一個名爲「office.pdf」的文件和郵件到的按鈕,如果我單擊它,該文件將作爲附件附加。可能嗎 ? –

回答

0

Basic版本(使用PHP):

$email = new PHPMailer(); 
$email->From  = '[email protected]'; 
$email->FromName = 'Your Name'; 
$email->Subject = 'Message Subject'; 
$email->Body  = $bodytext; 
$email->AddAddress('[email protected]'); 
$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('[email protected]', 'Laravel'); 

    $message->to('[email protected]')->cc('[email protected]'); 

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

參見:Laravel mail

+0

它也可以在laravel5中工作嗎? –

相關問題