On 4/8/2020 12:54 PM, Brian Adkins wrote:
I was able to write a simple wrapper around smtp-send-message and get it working through SendGrid in a few minutes (see below), but I wasn't able to find any examples of sending emails containing both a plain text version and HTML version. Can anyone point me to some examples?

Thanks,
Brian Adkins

You done the hard part.  Once you can send a plain text message, HTML is not much harder.

You have to construct a MIME multipart message, which has a particular internal structure.
See:
https://stackoverflow.com/questions/10631856/mime-type-to-satisfy-html-email-images-and-plain-text
http://www.enewsletterpro.com/articles/multi_part_mime_messages.asp
https://www.ietf.org/rfc/rfc1521.txt


My solution is to use message templates like the attached - which shows using not just multipart but also embedded graphics.  My program customizes the message by substituting for the '@' preceded "variables" in the template.  Feel free to (ab)use the same style or adapt it for your needs.

George


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b58bf51b-e970-1c54-bb24-e08996e43849%40comcast.net.
Subject: confirm password reset
MIME-Version: 1.0
Content-Type: multipart/alternative;
  boundary="__ALT__"

This is a MIME-encoded HTML message. If you are seeing
this text only section, your mail program either is too
old or is not configured properly.


--__ALT__
Content-Type: multipart/related;
  boundary="__REL__"

--__REL__
Content-Type: text/html; charset=us-ascii
Content-Disposition: inline
Content-ID: <body>

<html>
<body>
<p>@USERNAME,</p>

<p>A request has been received to reset your password<br>
   <br>
   If you wish to reset your password, please confirm by<br>
   clicking on the link below. Shortly you will receive<br>
   another email containing a new password .
   </p>

<p>
<a style="margin-left:20px" href=@LINK_0>Reset My Password</a>
</p>

<p><br>
   Message sent at @SEND_TIME on @SEND_DATE.<br>
   Links will expire at @LINK_TIME on @LINK_DATE.<br>
   If you believe you have received this message in error,<br>
   Please contact technical support and reference @REFERENCE.
   </p>
</body>
</html>


--__REL__
Content-Type: image/jpeg
Content-Disposition: inline
Content-Transfer-Encoding: base64
Content-ID: <logo>

  base64 encoded logo image goes here
  reference in body as <img src="cid:logo">

--__REL__
--__ALT__--

Reply via email to