I am trying to send a email with the MailPro Plugin with a attachment. Trough a headlessclient but the attachment doesn't get add to the email.
But i receive a message but without a attachment.
If i run the same code in my webclient it does work.
There are no errors in the log.
When i set some application outputs the file is there so the headlessclient sees the file.
- Code: Select all
var fsSettingsEmail = datasources.db.*.settings.getFoundSet();
fsSettingsEmail.loadAllRecords();
var vSmtp = plugins.MailPro.SMTPAccount();
vSmtp.host = fsSettingsEmail.smtp_host;
vSmtp.port = fsSettingsEmail.smtp_port;
vSmtp.userName = fsSettingsEmail.smtp_login_name;
vSmtp.password = fsSettingsEmail.smtp_password;
vSmtp.requiresAuthentication = fsSettingsEmail.is_authenticate_smtp;
vSmtp.useTLS = true;
if (!replyToAdress) {
replyToAdress = 'info@*.nl';
}
var message = vSmtp.createMessage(this.sendTo, replyToAdress, this.mailSubject, this.mailText);
message.htmlMsg = this.mailText;
message.replyTo = replyToAdress;
if (this.readReceipt) {
message['addHeader']("X-Confirm-Reading-To", replyToAdress);
message['addHeader']("Disposition-Notification-To", replyToAdress);
message['addHeader']("Return-Receipt-To", replyToAdress);
}
if (this.sendCc) {
message.ccAddresses = this.sendCc;
}
if (this.sendBcc) {
message.bccAddresses = this.sendBcc;
}
if (this.fileLocations) {
for (var x = 0; x < this.fileLocations.length; x++) {
var filePath = this.fileLocations[x];
if (file.canRead()) {
message.addAttachment(plugins.MailPro.Attachment(filePath));
}
}
}
vSmtp.sendMessageInBackground(message);
return true;