环境: 支付宝小程序云.
云对象: emailSend_Time.
目标: 定时调用nodemailer 邮件发送.
实测以下代码可以发送成功.
package.json
{
"name": "emailSend_Time",
"dependencies": {
"nodemailer": "^6.9.12"
},
"extensions": {
"uni-cloud-jql": {}
},
"cloudfunction-config": {
"memorySize": 256,
"triggers": [{
"name": "myEmailTrigger",
"type": "timer",
"config": "0 0 * * * * *"
}]
}
}
emailSend_Time
const nodemailer = require('nodemailer');
const sendEmail = async ({
to,
subject,
html
}) => {
const transporter = nodemailer.createTransport({
host: 'smtp.163.com',
port: 465,
secure: true,
auth: {
user: '邮箱',
pass: '授权码'
},
});
await transporter.sendMail({
from: {
name: 'XXXX',
address: '邮箱'
},
to,
subject,
html
});
}
module.exports = {
_timing: async function() {
await sendEmail({
to: '发送人邮箱',
subject: '幸福通知',
html: `<h1 style="text-align: center;"><span style="font-family: helvetica, arial, sans-serif; font-size: 36pt; color: #e03e2d;">测试</span></h1>`
})
return " "
},
sendEmail: sendEmail
}
0 个评论
要回复文章请先登录或注册