somnisoft / smtp-client

SMTP Client Library in C
Creative Commons Zero v1.0 Universal
108 stars 31 forks source link

Add an image in email content #8

Open Poyias opened 4 years ago

Poyias commented 4 years ago

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@email.de 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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> \ \ \ \ \ \ \ \

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

nnp19111990 commented 4 years ago

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: 250-SIZE 35882577

smtp Server: 250 SMTPUTF8

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: 250-SIZE 35882577

smtp Server: 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH

smtp Server: 250 SMTPUTF8 smtp Client: AUTH LOGIN c29jaW9tb25zdGVyMkBnbWFpbC5jb20=
smtp Server: 334 UGFzc3dvcmQ6

smtp Server: 235 2.7.0 Accepted smtp Client: MAIL FROM:abc@gmail..com
smtp Server: 250 2.1.0 OK q28sm10984480pfg.180 - gsmtp smtp Client: RCPT TO:xyz@gmail.com
smtp Server: 250 2.1.5 OK q28sm10984480pfg.180 - gsmtp

smtp Server: 354 Go ahead q28sm10984480pfg.180 - gsmtp smtp Client: Date: Sun, 31 May 2020 08:50:04 +0500
smtp Client: From: "Dharna" abc@gmail..com
smtp Client: Subject: This is TEST mail nirav
smtp Client: To: "Nirav" xyz@gmail.com
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 Server: 250 2.0.0 OK 1590895205 q28sm10984480pfg.180 - gsmtp

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

Thanks, Nirav

nnp19111990 commented 4 years ago

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.