问题
This is my SMTP settings in App.Config:
<system.net>
<mailSettings>
<smtp from="Reminder <reminder@myserver.com>">
<network host="mail.myserver.net" port="587" password="my password" userName="reminder@myserver.com" enableSsl="true"/>
</smtp>
</mailSettings>
</system.net>
And this is how I'm sending the emails:
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
smtpClient.Send(message);
this is working ! but the only problem is, my emails are going to spam folder and that's because they are missing Message-Id in their header. I use the same account in Thunderbird, when I send emails using thunderbird the Message-Id is added to my emails but it's not happening for the emails that are sent from my application.
I can add the header manually with something like :
message.Headers.Add("Message-Id","<3BD50098E401463AA228377848493927-1>");
But this Id is not a valid message-id and I will still get negative spam score for it. Any idea why this is happening ?
This is what I have in Thunderbird:
host: mail.korax.net /
authentication: normal password /
port: 587 /
security: STARTTLS
回答1:
Your SMTP server has to be configured to automatically include the message ID. If generating your own ID, it should follow RFC 2822 Section 3.6.4.
回答2:
Please also see this article here:
http://jarrett.co/post/1638578964/spamassassin-vs-system-net-mail
I was getting the same issue. System.Net.Mail
will not append a Message-Id automatically. But you can like so:
mailMessage.Headers.Add("Message-Id",
String.Format("<{0}@{1}>",
Guid.NewGuid().ToString(),
"mail.example.com"));
来源:https://stackoverflow.com/questions/6874964/why-emails-sent-by-net-smtpclient-are-missing-message-id