Это их документы, на которые я ссылаюсь:
https://www.smtp.com/developers/smtp-api/
Вот пример PHP, который они предоставили:
https://api.smtp.com/doc/PhpExample.html
Вот что я пробовал до сих пор - я убедился, что мой экспорт конфигурации корректен и что ключи API верны. Я заменил несколько вещей в коде примерами, чтобы не публиковать электронные письма в Интернете.
const rp = require("request-promise");
const moment = require("moment");
const config = require("../../config/smtp");
exports.notify = function(project, note) {
var options = {
method: "POST",
uri: config.uri,
headers: {
"content-type": "application/json"
},
body: {
recipients: {
to: [
{
name: "The Recipient",
address: "email@email.com"
}
]
},
originator: {
from: {
name: "Recipient's Notification System",
address: "notifications@email.com"
},
reply_to: {
name: "Do Not Reply",
address: "donotreply@email.com"
}
},
custom_headers: {},
subject:
"New note on Job " +
project._projectid +
" | " +
project.location.line1,
body: {
parts: [
{
type: "text/html",
charset: "UTF-8",
content:
"The following note was left on Project " +
project._projectid +
":\n\n" +
note.content +
"\n\n" +
"Author: " +
note.meta.author.name +
"at " +
moment(note.meta.created).format("MM/DD/YYYY hh:MMa")
}
],
attachments: []
}
},
json: true // Automatically stringifies the body to JSON
};
rp(options)
.then(res => {
console.log(res);
})
.catch(err => {
console.error(err);
});
};