如何使用 angular meteor 发送电子邮件然后在电子邮件中添加模板设计?我正在使用这个:
How can I send an email using angular meteor then add a template design in the email? I'm using this:
startup.js
smtp = {
用户名:'xxxx@gmail.com',
密码:'alpha123e',
服务器:'smtp.gmail.com',
端口:465
}
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server ) + ':' + smtp.port;
流星法
Meteor.methods({ sendEmail: function (to, from, subject, text) {
check([to, from, subject, text], [String]);
this.unblock();
Email.send({
to: to,
from: from,
subject: subject,
text: text
});
}
});
如果您想在电子邮件中使用模板化设计,那么您需要设置电子邮件的 html
属性,而不仅仅是 text
.
Email.send({
to: to,
from: from,
subject: subject,
html: "<h1>Hello World</h1>",
text: "Hello World"
});
您会发现 meteorhacks:ssr 包对于在服务器端呈现模板非常有用。
startup.js
smtp = {
用户名:'xxxx@gmail.com',
密码:'alpha123e',
服务器:'smtp.gmail.com',
端口:465
}
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server ) + ':' + smtp.port;
流星法
Meteor.methods({ sendEmail: function (to, from, subject, text) {
check([to, from, subject, text], [String]);
this.unblock();
Email.send({
to: to,
from: from,
subject: subject,
text: text
});
}
});
如果您想在电子邮件中使用模板化设计,那么您需要设置电子邮件的 html
属性,而不仅仅是 text
.
Email.send({
to: to,
from: from,
subject: subject,
html: "<h1>Hello World</h1>",
text: "Hello World"
});
您会发现 meteorhacks:ssr 包对于在服务器端呈现模板非常有用。