我正在使用nodemailer从我的Web应用程序发送电子邮件。 我已经使用“服务:'gmail'”将电子邮件从一个gmail帐户发送到另一个gmail帐户。
const nodemailer = require("nodemailer");
const promisify = require("es6-promisify");
const transport = nodemailer.createTransport({
service: 'gmail',
auth: {
user: "my gmail",
pass: "my password"
}
});
exports.send = async options => {
const mailOptions = {
from: options.email,
to: 'adikosh10@gmail.com',
subject: options.subject,
html: options.text,
text: options.text
};
const sendMail = promisify(transport.sendMail, transport);
return sendMail(mailOptions);
};
上面的代码有效,但是我无法使其适用于Outlook帐户。这意味着如果我通过电子邮件发送到Outlook或Hotmail帐户,则无法正常工作。
此外,我不知道如何注册多个服务,因此我不仅可以将电子邮件发送到任何电子邮件服务(hotmail,outlook,gmail ...),还可以将电子邮件发送到任何电子邮件服务。
我该怎么办?如果可以的话,请帮忙。
谢谢你, 阿迪
答案 0 :(得分:1)
在这里您可以执行以下操作:
首先,您可以使用let notificationCenter = AppDelegate().getNotificationCenter()
notificationCenter.getNotificationSettings(completionHandler: { (setting) in
if(setting.authorizationStatus == .denied){
})
}
npm package,这样您就可以轻松地做到这一点。
或者只是尝试通过
对于Outlook:
NodeJS Nodemailer Outlook
对于Hotmail:
var transport = nodemailer.createTransport("SMTP", {
host: "smtp-mail.outlook.com",
secureConnection: false,
port: 587,
auth: {
user: "XXXXXX@outlook.com",
pass: "XXXXXX"
},
tls: {
ciphers:'SSLv3'
}
});
一次在一起:尝试这样的事情
var transport = nodemailer.createTransport("SMTP", {
service: "hotmail",
auth: {
user: "XXXXX@hotmail.com",
pass: "XXXXX"
}
});
希望有帮助!!! 谢谢
答案 1 :(得分:0)
这是我尝试发送两封电子邮件的代码。它不起作用。
const nodemailer = require("nodemailer");
const promisify = require("es6-promisify");
const transport = nodemailer.createTransport({
service: 'gmail',
auth: {
user: "my gmail",
pass: "my gmail pass"
}
});
const transport2 = nodemailer.createTransport({
service: 'hotmail',
auth: {
user: "my hotmail",
pass: "my hotmail pass"
}
});
exports.send = async options => {
const mailOptions = {
to: 'my gmail',
subject: options.subject,
html: options.text,
text: options.text
};
const mailOptions2 = {
to: 'my hotmail',
subject: options.subject,
html: options.text,
text: options.text
};
const sendMail = promisify(transport.sendMail, transport);
return sendMail(mailOptions);
const sendMail2 = promisify(transport2.sendMail2, transport2);
return sendMail2(mailOptions2);
};