JSMA mail
Overview
With JSMA mail you can send an email
What can JSMA mail do for me?
The JSMA mail lets you dispatch multipart emails allowing you to send a plain text body and attachments along with your HTML email.
Index
Methods
The JSMA mail provides the following methods:
bool mail.send(recipients, subject, body, from_name, from_email, [plain_body], [portal], [files])
Dispatches an email to one or multiple recipients.
Returns true if sending was successful, or false if it wasn't.
Example
else if (itemAction === "recommendFriends")
{
var recommendationName = request.parameter("rn");
var recommendationFriends = request.parameter("rf");
var recommendationMessage = request.parameter("rm");
var portal = getCurrentPortal();
var mailTemplateBodyName = portal.get("customers.recommendFriendsMailBody");
var mailTemplateSubjectName = portal.get("customers.recommendFriendsMailSubject");
var mailSender = portal.get("service.mail");
var mailSenderName = portal.get("service.mailSender");
var mailTemplateBody = contents.findByName(mailTemplateBodyName);
var mailTemplateSubject = contents.findByName(mailTemplateSubjectName);
[...]
var recommendationFriendMails = recommendationFriends.split(",");
for (var i=0;i<recommendationFriendMails.length;i++)
{
var recommendationFriendMail = recommendationFriendMails[i].trim();
mail.send(recommendationFriendMail, mailTemplateSubject.content, mailTemplateBody.content, mailSenderName, mailSender);
}
[...]
}
Parameter recipients:string[] (required)
A string or an array of strings which will be used as email recipients.
Parameter subject:string (required)
The email subject
Parameter body:string (required)
The email body.
Parameter from_name:string (required)
The name that will displayed next to the sender's email address.
Parameter from_email:string (required)
The email address that will be used in the FROM field of the message.
Parameter plain_body:string (optional)
An alternative plaintext body for the message.
Parameter portal:portal (optional)
A JSMA portal from which the smpt credentials shall be used.
Parameter files:file[] (optional)
A single JSMA file or a list.
The file(s) will be used as attachment(s) in the message.