通过Firebase云功能发送电子邮件 [英] Sending email through firebase cloud functions
本文介绍了通过Firebase云功能发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含用户电子邮件的大查询表,我想向他们发送时事通讯电子邮件(表中约500行)当该函数运行时,在该超时后它仅向30-35个用户发送电子邮件,如果我将列表减少到100,它将在一个电子邮件ID上多次发送电子邮件下面是我的代码-:bigQuery.query({
I have a big query table containing email of the users and i want to send them a newsletter email ( around 500 rows in table) When the function runs it only sends email to 30-35 users after that time out, if i reduce the list to 100 it sends email for the multiple time on one email id Below is my code -: bigQuery.query({
exports.date = functions.https.onRequest((req, res) => {
const bigQuery = bigquery({ projectId: 'littleone-150007' });
var someVar = [];
var someVar1 =[];
bigQuery.query({
query:`Select email from table`
useLegacySql: false
}).then(function (rows) {
setValue(rows);
});
function setValue(value) {
someVar = value;
//console.log(someVar); // data is printing here
var someVar = value[0].map(function(o) { return o.email; });
//console.log(someVar);
var i,datalength;
datalength = someVar.length;
var emailsubj=`subject`;
var emailbody=`newsleter body`
for(i=0;i<datalength;i++){
//console.log(someVar[i])
const mailOptions = {
from: `Madhu from Mylo <noreply@firebase.com>`,
to: someVar[i],
bcc: `qa@myloapp.in`
}
mailOptions.subject = emailsubj ;
mailOptions.html = emailbody;
mailTransport.sendMail(mailOptions).then(() => {
console.log('Uninstall mail sent :', someVar[i]);
});
}
我需要更改的内容,以便只有一封邮件发送给用户.
What i need to change so that only one mail will go to user.??
推荐答案
如果您这样存储电子邮件:
If you store your emails like this:
var someVar = ['someemail@mail.com', 'another@mail.com'];
您可以执行以下操作:
var someVar = ['client@mail.com', 'another@mail.com'];
var sendTo = someVar.join(',');
var mailOptions = {
from: 'truironusa@gmail.com', // sender address
to: sendTo, // list of receivers
subject: 'My newsletter', // Subject line
html: '<b>content</b>', // html body
// plain: 'Some text' // plain text
};
这篇关于通过Firebase云功能发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文