Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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->AddEmbeddedImage('2.jpg', '2img', '2.jpg');
$mail->Subject  =  "Order Form:  Contact form submitted";
$mail->Body     =  $body . 'img src="../../photo/2img" ;

note: i have dropped html tag befor img as I get error sending this Q.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
280 views
Welcome To Ask or Share your Answers For Others

1 Answer

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: <img alt="PHPMailer" src="cid:my-attach"> Here is an image!';

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...