2***@qq.com
2***@qq.com
  • 发布:2025-07-19 18:01
  • 更新:2025-07-21 15:43
  • 阅读:153

smtp发邮件开发调试可以发,体验版和线上版本发不了

分类:uni-app

代码如下;依赖已经在目录下安装过了并且上传云函数了

'use strict';
const nodemailer = require('nodemailer')
exports.main = async (event, context) => {
let transporter = nodemailer.createTransport({
host: 'smtp.qq.com',
secureConnection: true,
port: 465,
secure: true,
auth: {
user: 'xxxxx@qq.com', // 你的邮箱账号
pass: 'xxxxx' // 你的邮箱密码或授权码
}
})
const info = await transporter.sendMail({
from: 'xxx@qq.com',
to: event.to ? event.to : '',
subject: event.subject ? event.subject : '',
text: event.text ? event.text : '',
html: event.html ? event.html : ''
})
if (info.messageId) {
return {
code: 0,
msg: '发送成功'
}
} else {
return {
code: 1,
msg: '发送失败',
info
}
}
}

2025-07-19 18:01 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

是哪个平台出现的?有报错信息吗?

要回复问题请先登录注册