Home > Uncategorized > #SMTPJS now supports multiple attachments, ReplyTo and sender name

#SMTPJS now supports multiple attachments, ReplyTo and sender name


In case you’ve missed it, SMTPJS.com has just released the V3 Library, this offers a cleaner object model, promises, and new features, such as multiple attachments, Reply-to, and sender name

Here’s an example on how to send multiple attachments:

To : “recipient@website.com”,
From : “sender@website.com”,
FromName: “Joe Sender”,
ReplyAddress: “noreply@website.com”,
Subject : “This is the subject”,
Body : “This is the body”,
Attachments : [
name : “padlock.png”,
path : “https://www.smtpjs.com/img/ipad.png”
name : “spam.png”,
path : “https://www.smtpjs.com/img/iphone.png”
message => alert(message)

Obviously, you need to change the secureToken property above, or pass in naked SMTP credentials.

Here’s another example, imagine you want to offer an upload form, so people can upload a file to be sent to you – without putting the file on your server.

First, here’s the required line of HTML:

<input type=”fileid=”fileuploadonchange=”uploadFileToServer()” />

Then here’s the uploadFileToServer() method;

function uploadFileToServer() {
var file = event.srcElement.files[0];
var reader = new FileReader();
reader.onload = function () {
var datauri = “data:” + file.type + “;base64,” + btoa(reader.result);
To : “recipient@website.com”,
From : “sender@isp.com”,
Subject : “The subject”,
Body : “See file attached”,
Attachments : [
name : file.name,
data : datauri
message => alert(message)
reader.onerror = function() {
console.log(‘there are some problems’);

Categories: Uncategorized
  1. jin
    January 21, 2019 at 5:50 pm

    Thanks for your sharing easy/free software.
    btw, how can I send email as HTML page rather than message or attachment



    • January 21, 2019 at 5:59 pm


      The body can be in HTML format, you could put a there for a new line, for example.

      If you want to have a complex, richly formatted email, then the best thing to do is use a templating engine like Mustache.js, and define the email as a hidden div on the page



      • jin
        January 21, 2019 at 6:22 pm

        Thanks for your quick reply
        Could you show a simple example about “body can be in HTML format”?



  2. jin
    January 21, 2019 at 6:07 pm

    it can send email as HTML page?


  1. December 7, 2018 at 9:26 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: