亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當我發送電子郵件/swiftmailer 時圖像不顯示

當我發送電子郵件/swiftmailer 時圖像不顯示

PHP
繁星淼淼 2023-10-15 17:04:40
我目前正在使用 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'

);    

?>


查看完整回答
反對 回復 2023-10-15
?
臨摹微笑

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 中嵌入圖像。


查看完整回答
反對 回復 2023-10-15
  • 2 回答
  • 0 關注
  • 163 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號