简体   繁体   English

通过nodemailer从我的服务器发送的电子邮件以垃圾邮件的形式通过:(未知发件人)

[英]Emails sent via nodemailer from my server come through as spam: (unknown sender)

First time using Node and working with email configuration. 首次使用Node并使用电子邮件配置。 I downloaded this application from here , it works (uses mustache.js to generate templates for the emails), but the test email ends up in my gmail spam. 从这里下载了此应用程序 ,它可以运行(使用mustache.js生成电子邮件模板),但是测试电子邮件最终出现在我的gmail垃圾邮件中。

from:   via vps1234.inmotionhosting.com 
to: thisisme@gmail.com
date:   Tue, Aug 8, 2017 at 5:30 PM
subject:    Thanks! and review your experience
mailed-by:  vps1234.inmotionhosting.com
security:    Standard encryption (TLS) Learn more

- -

var nodemailer = require('nodemailer'); 
let transporter = nodemailer.createTransport({
      service: ' ',
      secure: false,  
      port: 25,
      auth: { 
            user: 'thisisme@mydomain.com',
            pass: 'password1234'
        },
      tls: {
        rejectUnauthorized: false,
    }
 }),


EmailTemplate = require('email-templates').EmailTemplate,
path = require('path'),
Promise = require('bluebird');

let users = [
    {
        name: 'John',
        note: 'I found your purse',
        email: 'recipient@gmail.com',
    }
];



function sendEmail (obj) {
    return transporter.sendMail(obj);
}

function loadTemplate (templateName, contexts) {
    let template = new EmailTemplate(path.join(__dirname, 'templates', templateName));
    return Promise.all(contexts.map((context) => {
        return new Promise((resolve, reject) => {
            template.render(context, (err, result) => {
                if (err) reject(err);
                else resolve({
                    email: result,
                    context,
                });
            });
        });
    }));
}

loadTemplate('welcome', users).then((results) => {
    return Promise.all(results.map((result) => {
        sendEmail({
            to: result.context.email,
            from: 'Me :)',
            subject: result.email.subject,
            html: result.email.html,
            text: result.email.text,
        });
    }));
}).then(() => {
    console.log('Yay!');
});

This is Nodemailer boilerplate, which I tested also on my server, and it worked correctly, and the email did not get flagged: 这是Nodemailer样板文件,我也在服务器上对其进行了测试,并且工作正常,并且未标记电子邮件:

var nodemailer = require('nodemailer');

let transporter = nodemailer.createTransport({
    service: ' ',
    secure: false,
    port: 25,
    auth:{
        user: 'thisisme@mydomain.com',
        pass: 'password1234'
    },
    tls: {
        rejectUnauthorized: false,
    }
});


let helperOptions = {
    from: '<thisisme@mydomain.com>',
    to: 'recipient1234@gmail.com',
};

transporter.sendMail(helperOptions, (error, info) =>{
    if(error){return alert(error);}
    console.log("sent" . info);
})

A message being marked as spam is not so much a function of the code that generated it but of a few other things such as: 标记为垃圾邮件的邮件与其产生代码的功能无关,而是其他一些功能,例如:

  • the actual content (text, links etc) 实际内容(文本,链接等)
  • the domain it came from 它来自的域

The first issue is just something you have to play with. 第一个问题就是您必须玩的东西。 There are services such as MailMonitor and others that help you tweak your content to see how gmail and others handle it. 有诸如MailMonitor等服务,可帮助您调整内容以查看gmail及其他人如何处理内容。 Wording, HTML vs plain text, links vs none, etc all play a part. 措辞,HTML与纯文本,链接与无文本等都发挥了作用。

As far as the domain, you'll want to setup your SPF (Sender Policy Framework) and DKIM entries to essentially validate your domain as a proper sender. 就域而言,您需要设置SPF(发件人策略框架)和DKIM条目,以从本质上验证您的域是否是适当的发送者。 The "unknown sender" is most likely a missing SPF record. “未知发件人”很可能是丢失的SPF记录。

For SPF here's an article . 对于SPF,这是一篇文章 For DKIM here's another 对于DKIM,这是另一个

Note that I just googled for this - they seemed like good articles but I am sure there are other great sources. 请注意,我只是在Google上搜索-它们看起来像是不错的文章,但我相信还有其他很棒的资源。

The gist of it is that you'll want to create a couple of TXT entries in your DNS. 要点是,您要在DNS中创建几个TXT条目。 There are tools such as SPF generators to help you with this. 有一些工具,例如SPF生成器可以帮助您解决此问题。 It's not as complex as it may sound. 它并不像听起来那样复杂。

Once that is done you might still end up in spam but it will certainly help. 完成此操作后,您可能仍然会陷入垃圾邮件,但肯定会有所帮助。 You can experiment with services such as Amazon SES and SendGrid which might provide better sending "validity" than your current SMTP server. 您可以尝试使用诸如Amazon SESSendGrid之类的服务,这些服务可能比当前的SMTP服务器提供更好的发送“有效性”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从本地主机通过nodemailer发送的电子邮件未传递 - Emails sent from localhost with nodemailer are not delivered 使用 nodemailer 从托管在 hostmonster 上的 SMTP 服务器发送的电子邮件未发送给收件人 - Emails sent from SMTP server hosted on hostmonster using nodemailer are not delivering to the recipients 带有附件的电子邮件使用Nodemailer空出 - Emails with attachments come up empty using Nodemailer 如何通过 Nodemailer Gmail 从 Heroku 发送电子邮件? - How can I send emails via Nodemailer Gmail from Heroku? Email 通过 nodemailer 发送进入垃圾邮件 gmail - Email send through nodemailer goes into spam for gmail 从服务器从nodemailer发送电子邮件时出错 - Getting error while sending emails from nodemailer from server 不使用 MailComposer 和 Nodemailer 发送 BBC 电子邮件 - BBC emails not being sent with MailComposer and Nodemailer Nodemailer google workspace 在开发中工作,但在生产中将电子邮件 go 发送到垃圾邮件 - Nodemailer google workspace works in Dev but in production the emails go to spam Hotmail阻止来自nodemailer的电子邮件 - Hotmail blocking emails from nodemailer 谷歌应用程序退回从 nodemailer 发送的电子邮件,但 gmail 可以正常接收 - Google apps bounces emails sent from nodemailer, but gmail receives them fine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM