使用node.js配合QQ域名邮箱完成邮件发送。配置域名邮箱。详情请查看QQ邮箱。在账户项中,勾选启用SMTP服务获取密码。安装节点邮件模块installnpminstallnodemailernodemailer-smtp-transport--saveImportmoduleconstnodemailer=require('nodemailer');constsmtpTransport=require('nodemailer-smtp-transport');具体实现代码//导入邮件模块varnodemailer=require('nodemailer');varsmtpTransport=require('nodemailer-smtp-transport');//开启一个SMTP连接池vartransport=nodemailer.createTransport(smtpTransport({host:"smtp.qq.com",//qq邮箱主机secure:true,//使用SSLsecureConnection:true,//使用SSLport:465,//SMTPportauth:{user:"noreply@binlive.cn",//accountyourcustomdomainnameemailaccountpass:"olncjtfcim1232312ahj"//password你打开SMPT获取密码}}));//发送邮件路由router.post('/api/email',function(req,res){varquery=req.body.email;//设置邮件内容为拼接html美化发送内容lethtmlcon='
