本文介绍了节点邮件程序错误:“不支持的配置,将Nodemailer降级到v0.7.1以使用它”在本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我是nodejs的新手,并试图从 nodemailer 模块发送邮件,但是它有错误,即不支持的配置,将Nodemailer降级到v0.7.1以使用它

I am new to nodejs and try to send mail from nodemailer module but it has error i.e "Unsupported configuration, downgrade Nodemailer to v0.7.1 to use it".

这是我的代码: -

Here is my code:-

var nodemailer = require('nodemailer');
var mailTransport = nodemailer.createTransport('SMTP', {
    service: 'Gmail',
    auth: {
        user: '[email protected]',
        pass: 'xxxxxxxxx',
    }
});

mailTransport.sendMail({
    from: '"ABC" <[email protected]>',
    to: '[email protected]',
    subject: 'Test',
    text: 'Thank you for contact.',
}, function (err) {
    if (err)
        console.error('Unable to send email: ' + err);
});


推荐答案

要使用nodemailer v1,请尝试实现此代码。

To use nodemailer v1, try to implement this code.

var express = require('express');
var nodemailer = require("nodemailer");
var smtpTransport = require("nodemailer-smtp-transport")
var app = express();

var smtpTransport = nodemailer.createTransport(smtpTransport({
    host : "YOUR SMTP SERVER ADDRESS",
    secureConnection : false,
    port: 587,
    auth : {
        user : "YourEmail",
        pass : "YourEmailPassword"
    }
}));
app.get('/send',function(req,res){
    var mailOptions={
        from : "YourEmail",
        to : "Recipient'sEmail",
        subject : "Your Subject",
        text : "Your Text",
        html : "HTML GENERATED",
        attachments : [
            {   // file on disk as an attachment
                filename: 'text3.txt',
                path: 'Your File path' // stream this file
            }
        ]
    }
    console.log(mailOptions);
    smtpTransport.sendMail(mailOptions, function(error, response){
        if(error){
            console.log(error);
            res.end("error");
        }else{
            console.log(response.response.toString());
            console.log("Message sent: " + response.message);
            res.end("sent");
        }
    });
});

app.listen(3000,function(){
    console.log("Express Started on Port 3000");
});

这篇关于节点邮件程序错误:“不支持的配置,将Nodemailer降级到v0.7.1以使用它”在本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 03:05