我目前正在使用 Swiftmailer 發送電子郵件。一切正常,正在發送電子郵件,但是電子郵件沒有顯示我放入的徽標。以下是代碼:require_once 'vendor/autoload.php';require_once 'config/constants.php';// Create the Transport $transport = (new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl')) ->setUsername(EMAIL) ->setPassword(PASSWORD);// Create the Mailer using your created Transport$mailer = new Swift_Mailer($transport);function sendVerificationEmail($userEmail, $token){ global $mailer; $body = '<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Verify Email</title></head><body><div class="not-verified-container"> <img src="logo.svg" class="mazaw-logo-not-verified"> <div class="container-without-logo"> <div class="not-verified-texts"> <h2>Account Verification</h2> </div> </div></div></body></html>'; // Create a message $message = (new Swift_Message('Account Verification')) ->setFrom(EMAIL) ->setTo($userEmail) ->setBody($body, 'text/html');// Send the message $result = $mailer->send($message);}如果有人能看一下我做錯了什么,我將非常非常感激。謝謝你!
2 回答

慕姐8265434
TA貢獻1813條經驗 獲得超2個贊
嵌入應該可以正常工作
<?php
$message = new Swift_Message('Your subject');
$message->setBody(
'<html>' .
' <body>' .
' <img src="' . $message->embed(Swift_Image::fromPath('image.png')) . '" />' .
' </body>' .
'</html>',
'text/html'
);
?>

臨摹微笑
TA貢獻1982條經驗 獲得超2個贊
您需要將徽標圖像作為附件包含在電子郵件中。google 搜索時,
$uploadedFileName = CUploadedFile::getInstance($model,'career_resume');?
$uploadedFileName = $uploadedFile->tempName; // will be something like 'myfile.jpg'
$swiftAttachment = Swift_Attachment::fromPath($uploadedFileName);
$message->attach($swiftAttachment);
還谷歌如何在 Swiftmailer 中嵌入圖像。
- 2 回答
- 0 關注
- 163 瀏覽
添加回答
舉報
0/150
提交
取消