smtp-client icon indicating copy to clipboard operation
smtp-client copied to clipboard

Add an image in email content

Open Poyias opened this issue 4 years ago • 2 comments

Hi,

Your library is working great and I am very happy with it. I am trying to do more complicated things like adding an image to the content of the email.

I found this example online. Can we do something like this? Especially the bold part onwards. Thanks Andreas

To: [email protected] Subject: ... Content-Type: multipart/related; boundary="------------090303020209010600070908"

This is a multi-part message in MIME format. --------------090303020209010600070908 Content-Type: text/html; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit

<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"> </head> <body bgcolor="#ffffff" text="#000000"> <img src="cid:part1.06090408.01060107" alt=""> </body> </html>

--------------090303020209010600070908 Content-Type: image/png; name="moz-screenshot.png" Content-Transfer-Encoding: base64 Content-ID: <part1.06090408.01060107> Content-Disposition: inline; filename="moz-screenshot.png"

Poyias avatar May 13 '20 14:05 Poyias

Hello Andreas, I also tried with jpg image , i am able to receive the mail and jpg attachment , but not able to open it (may be data available in base64 which may not be supported by gmail). Please find the below logs,

[smtp Server]: 220 smtp.gmail.com ESMTP q28sm10984480pfg.180 - gsmtp [smtp Client]: EHLO smtp
[smtp Server]: 250-smtp.gmail.com at your service, [2405:205:c823:480c:6d2f:36a6:f106:6e98] [smtp Server]: 250-SIZE 35882577 [smtp Server]: 250-8BITMIME [smtp Server]: 250-STARTTLS [smtp Server]: 250-ENHANCEDSTATUSCODES [smtp Server]: 250-PIPELINING [smtp Server]: 250-CHUNKING [smtp Server]: 250 SMTPUTF8 [smtp Client]: STARTTLS
[smtp Server]: 220 2.0.0 Ready to start TLS [smtp Client]: EHLO smtp
[smtp Server]: 250-smtp.gmail.com at your service, [2405:205:c823:480c:6d2f:36a6:f106:6e98] [smtp Server]: 250-SIZE 35882577 [smtp Server]: 250-8BITMIME [smtp Server]: 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH [smtp Server]: 250-ENHANCEDSTATUSCODES [smtp Server]: 250-PIPELINING [smtp Server]: 250-CHUNKING [smtp Server]: 250 SMTPUTF8 [smtp Client]: AUTH LOGIN c29jaW9tb25zdGVyMkBnbWFpbC5jb20=
[smtp Server]: 334 UGFzc3dvcmQ6 [smtp Client]: cWRjbXl1d2FodXljc2p5Zg==
[smtp Server]: 235 2.7.0 Accepted [smtp Client]: MAIL FROM:<[email protected]>
[smtp Server]: 250 2.1.0 OK q28sm10984480pfg.180 - gsmtp [smtp Client]: RCPT TO:[email protected]
[smtp Server]: 250 2.1.5 OK q28sm10984480pfg.180 - gsmtp [smtp Client]: DATA
[smtp Server]: 354 Go ahead q28sm10984480pfg.180 - gsmtp [smtp Client]: Date: Sun, 31 May 2020 08:50:04 +0500
[smtp Client]: From: "Dharna" <[email protected]>
[smtp Client]: Subject: This is TEST mail nirav
[smtp Client]: To: "Nirav" [email protected]
[smtp Client]: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=mimePCWSNWMUPK Multipart MIME message. --mimePCWSNWMUPK Content-Type: text/plain; charset="UTF-8" Helllo buddy
[smtp Client]: --mimePCWSNWMUPK Content-Type: application/octet-stream Content-Disposition: attachment; filename="world.jpg" Content-Transfer-Encoding: base64 VGVzdCBlbWFpbCBhdHRhY2htZW50Lg==
[smtp Client]: --mimePCWSNWMUPK--
[smtp Client]: .
[smtp Server]: 250 2.0.0 OK 1590895205 q28sm10984480pfg.180 - gsmtp [smtp Client]: QUIT

How can i receive .jpg image in original form??

Thanks, Nirav

nnp19111990 avatar May 31 '20 03:05 nnp19111990

Hello Andreas, by using smtp_attachment_add_path("path of .jpeg") api , i can successfully able to fetch the image at receiver end. Resolving the problem.

nnp19111990 avatar Jun 01 '20 14:06 nnp19111990