Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an image in email content #8

Open
Poyias opened this issue May 13, 2020 · 2 comments
Open

Add an image in email content #8

Poyias opened this issue May 13, 2020 · 2 comments

Comments

@Poyias
Copy link

Poyias commented May 13, 2020

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

<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"

@nnp19111990
Copy link

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:<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 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" <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 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
Copy link

nnp19111990 commented Jun 1, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants