Skip to content

Instantly share code, notes, and snippets.

@sudharsan203
Forked from gr2m/email_dreamcode.js
Created July 18, 2019 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudharsan203/754d2f9b7fe9de64245b04d44bf291d3 to your computer and use it in GitHub Desktop.
Save sudharsan203/754d2f9b7fe9de64245b04d44bf291d3 to your computer and use it in GitHub Desktop.
Imagine you could send emails with JavaScript, multipart, and with attachments?! How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// send text email
sendEmail({
subject: "Hello, World!",
text: "This mail has been sent from the frontend",
to: "joe@exam.pl"
})
// send multipart text / html email
sendEmail({
subject: "Hello, World!",
text: "This mail has been sent from the frontend",
html: "<p>This mail has been sent from the frontend</p>",
to: "joe@exam.pl"
})
// send multipart with attachment
sendEmail({
subject: "Hello, World!",
text: "This mail has been sent from the frontend",
html: "<p>This mail has been sent from the frontend</p>",
to: "gregor@martynus.net",
attachments: [
convert( document.body ).to("screenshot.png"),
{ filename: "info.text", data: "Some info about the page"}
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment