Send email with PHPMailer - embed image in body

前端 未结 2 602
长发绾君心
长发绾君心 2020-11-28 20:27

I\'m trying to send HTML mail, with PHPMailer, with images. The body is loaded from a html file, that contains all the info.

When sending the mail, the image does no

2条回答
  •  借酒劲吻你
    2020-11-28 20:35

    According to PHPMailer Manual, full answer would be :

    $mail->AddEmbeddedImage(filename, cid, name);
    //Example
    $mail->AddEmbeddedImage('my-photo.jpg', 'my-photo', 'my-photo.jpg '); 
    

    Use Case :

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

    If you want to display an image with a remote URL :

    $mail->addStringAttachment(file_get_contents("url"), "filename");
    

提交回复
热议问题