smtpjs

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 , Reply-to, and name

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

Email.send({
SecureToken : “XXXXX-XXXX-XXXX-XXXX-XXXXXXX”,
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”,
: “https://www.smtpjs.com/img/ipad.png”
},
{
name : “spam.png”,
path : “https://www.smtpjs.com/img/iphone.png”
}
]
}).then(
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.readAsBinaryString(file);
reader.onload = function () {
var datauri = “data:” + file.type + “;base64,” + btoa(reader.result);
Email.send({
SecureToken : “XXXX-XXXX-XXXX-XXXX-XXXX”,
To : “recipient@website.com”,
From : “sender@isp.com”,
Subject : “The subject”,
Body : “See file attached”,
Attachments : [
{
name : file.name,
data : datauri
}
]
}).then(
message => alert(message)
);
};
reader.onerror = function() {
console.log(‘there are some problems’);
};
}



Source link
thanks you RSS link
( https://blog.dotnetframework.org/2018/12/07/-now--multiple-attachments-replyto-and-sender-name/)

LEAVE A REPLY

Please enter your comment!
Please enter your name here