I am sending email through nodemailer it goes into inbox of gmail if i run from local server but goes into spam of gmail if i run script from microsoft azure server. following is my script
我通过nodemailer发送电子邮件,如果我从本地服务器运行,它进入Gmail的收件箱,但如果我从microsoft azure服务器运行脚本,则进入gmail的垃圾邮件。以下是我的脚本
var nodemailer = require('nodemailer');
var EmailTemplates = require('swig-email-templates');
var smtpConfig = {
service: 'smtp.office365.com',
host: 'smtp.office365.com',
port: 587,
starttls: {
enable: true
},
secureConnection: true,
auth: {
user: 'xxxxx@yyyy.com',
pass: 'zzzzzz'
}
}
var templates = new EmailTemplates();
var transporter = nodemailer.createTransport(smtpConfig);
var context = {
username:'Rajesh',
email:'xxxxx@gmail.com',
link : 'www.google.co.in'
};
templates.render('activate_email.html', context, function(err, html,text, subject) {
transporter.sendMail({
from: '"Product Name????" <no-reply@xxxxx.com>', // sender address
to: 'xxxx@gmail.com',
subject: 'Account activation',
html: html,
text:text
});
});
2 个解决方案
#1
6
The truth is there is no simple one line solutions for your problem :) There are numerous reasons why this can happen, and here are some of them:
事实上,没有简单的一行解决方案可以解决你的问题:)有很多原因导致这种情况发生,以下是其中一些:
-
Your host is marked as a spam - this happens if you have not verified your e-mail or you are sending too much e-mails from the same host. Shared hosting is commonly marked as such, and therefore mail server will regularly mark them as a spam
您的主机被标记为垃圾邮件 - 如果您未验证电子邮件或从同一主机发送过多电子邮件,则会发生这种情况。共享主机通常标记为这样,因此邮件服务器会定期将它们标记为垃圾邮件
-
Your
from
field is different than the one you're allowed to use - as I see you're using smtp, there are strict rules for the mail you can send. Of course you can always send e-mail frommark@facebook.com
, but since your SMTP's host is not facebook.com, your e-mail will pretty sure marked as spam你的字段与你允许使用的字段不同 - 因为我看到你使用的是smtp,你可以发送的邮件有严格的规则。当然你可以随时发送来自mark@facebook.com的电子邮件,但由于你的SMTP主机不是facebook.com,你的电子邮件肯定会被标记为垃圾邮件
-
You can sign your e-mail in many various mails, assuring the servers that this e-mail is send from you and it has proper signature. Check online for the ways to do so.
您可以在许多不同的邮件中签署您的电子邮件,确保服务器发送此电子邮件并且具有适当的签名。在线查看方法。
-
While developing you have sent numerous alike e-mails - sending the very same "test" e-mail is a common reason for your e-mails to get blacklisted
在开发过程中,您发送了大量类似的电子邮件 - 发送相同的“测试”电子邮件是您的电子邮件被列入黑名单的常见原因
Unfortunately as I said there is no one real reason, there could be many of them. I hope this helps at least a little :)
不幸的是,正如我所说,没有一个真正的原因,可能有很多。我希望这至少有一点帮助:)
#2
4
Please get rid of the ???? and try sending it again. I read in a article once that email clients don't like those icons because a lot of spammers are using them.
请摆脱????并尝试再次发送。我曾经读过一篇文章,因为很多垃圾邮件发送者正在使用它们,因此电子邮件客户端不喜欢这些图标。
Try sending it to multiple gmail accounts. Other than that there's nothing wrong with the code. If you're on a shared hosting or local host it could also go into the junk folder. In that case you would have to look into sending the emails from a different IP, preferred in the same country as where you will send the emails to.
尝试将其发送到多个Gmail帐户。除此之外,代码没有任何问题。如果您在共享主机或本地主机上,它也可以进入垃圾文件夹。在这种情况下,您将不得不考虑从不同的IP发送电子邮件,首选的国家/地区与发送电子邮件的国家/地区相同。
But first try to remove that icon!
但首先尝试删除该图标!
PS. I would make this answer as a comment but I can't due to low rep.
PS。我会把这个答案作为评论,但我不能因为低代表。
#1
6
The truth is there is no simple one line solutions for your problem :) There are numerous reasons why this can happen, and here are some of them:
事实上,没有简单的一行解决方案可以解决你的问题:)有很多原因导致这种情况发生,以下是其中一些:
-
Your host is marked as a spam - this happens if you have not verified your e-mail or you are sending too much e-mails from the same host. Shared hosting is commonly marked as such, and therefore mail server will regularly mark them as a spam
您的主机被标记为垃圾邮件 - 如果您未验证电子邮件或从同一主机发送过多电子邮件,则会发生这种情况。共享主机通常标记为这样,因此邮件服务器会定期将它们标记为垃圾邮件
-
Your
from
field is different than the one you're allowed to use - as I see you're using smtp, there are strict rules for the mail you can send. Of course you can always send e-mail frommark@facebook.com
, but since your SMTP's host is not facebook.com, your e-mail will pretty sure marked as spam你的字段与你允许使用的字段不同 - 因为我看到你使用的是smtp,你可以发送的邮件有严格的规则。当然你可以随时发送来自mark@facebook.com的电子邮件,但由于你的SMTP主机不是facebook.com,你的电子邮件肯定会被标记为垃圾邮件
-
You can sign your e-mail in many various mails, assuring the servers that this e-mail is send from you and it has proper signature. Check online for the ways to do so.
您可以在许多不同的邮件中签署您的电子邮件,确保服务器发送此电子邮件并且具有适当的签名。在线查看方法。
-
While developing you have sent numerous alike e-mails - sending the very same "test" e-mail is a common reason for your e-mails to get blacklisted
在开发过程中,您发送了大量类似的电子邮件 - 发送相同的“测试”电子邮件是您的电子邮件被列入黑名单的常见原因
Unfortunately as I said there is no one real reason, there could be many of them. I hope this helps at least a little :)
不幸的是,正如我所说,没有一个真正的原因,可能有很多。我希望这至少有一点帮助:)
#2
4
Please get rid of the ???? and try sending it again. I read in a article once that email clients don't like those icons because a lot of spammers are using them.
请摆脱????并尝试再次发送。我曾经读过一篇文章,因为很多垃圾邮件发送者正在使用它们,因此电子邮件客户端不喜欢这些图标。
Try sending it to multiple gmail accounts. Other than that there's nothing wrong with the code. If you're on a shared hosting or local host it could also go into the junk folder. In that case you would have to look into sending the emails from a different IP, preferred in the same country as where you will send the emails to.
尝试将其发送到多个Gmail帐户。除此之外,代码没有任何问题。如果您在共享主机或本地主机上,它也可以进入垃圾文件夹。在这种情况下,您将不得不考虑从不同的IP发送电子邮件,首选的国家/地区与发送电子邮件的国家/地区相同。
But first try to remove that icon!
但首先尝试删除该图标!
PS. I would make this answer as a comment but I can't due to low rep.
PS。我会把这个答案作为评论,但我不能因为低代表。