How can i attach an image using Phpmailer?

前端 未结 2 1601
有刺的猬
有刺的猬 2020-12-15 23:29

I am using phphmailer and have attached an image, it shows only the image like an icon rather than image itself here is my code could you help.

$mail->Ad         


        
2条回答
  •  不知归路
    2020-12-15 23:50

    Per PHPMailer Manual, you sould use the method AddEmbeddedImage

    $mail->AddEmbeddedImage(filename, cid, name);
    By using this function with this example's value above, results in this code:
    $mail->AddEmbeddedImage('my-photo.jpg', 'my-photo', 'my-photo.jpg '); 
    

    like this:

    $mail->AddEmbeddedImage("rocks.png", "my-attach", "rocks.png");
    $mail->Body = 'Embedded Image: PHPMailer Here is an image!';
    

    so cid:my-attach will be replaced with the inline-source of the image that's inside the email body

提交回复
热议问题