Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why emails sent by .NET SmtpClient are missing Message-Id?

Tags:

c#

.net

asp.net

This is my SMTP settings in App.Config:

<system.net>
    <mailSettings>
      <smtp from="Reminder &lt;[email protected]&gt;">
        <network host="mail.myserver.net" port="587" password="my password" userName="[email protected]" 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

like image 855
Tohid Avatar asked Jul 29 '11 14:07

Tohid


1 Answers

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.

like image 60
Mark Cidade Avatar answered Nov 04 '22 11:11

Mark Cidade