How to implement sender ID when sending emails through C #?

I just heard how Joel and Jeff talk about the sender ID in their podcast number 83, and it occurred to me that this is exactly what I need for the site I'm working on.

About 90% of all emails sent from the server bounce or are similar, probably because the server is not “verified”.

I have an SPF record for the server, but that is pretty much the same.

So, since StackOverflow solved these problems, I think the sender id should be fine.

As far as I can tell from wikipedia, you need to change the email header when sending emails - how can I do this with C #?

Also, what do I need to configure DNS wise, etc. to make this work?

Or am I on the completely wrong path here?

Edit: I use the standard SmtpClient class in C # to send emails, and I include both plain text and the HTML version of the mailbox.

+5
source share
2 answers

If you send mail on behalf of another user and want it to be accepted, you may need to do the following:

To your MailMessage object:

mail.To = new MailAddress("email@tosomeone.com", "To Someone");
mail.From = new MailAddress("sendinguser@fromsomeone.com", "Sending User");
mail.Sender = new MailAddress("serveraddress@your-domain-with-spf.com", "Your Server");
mail.ReplyTo = new MailAddress("sendinguser@fromsomeone.com", "Sending User");

This will create the appropriate headers needed to verify the correctness of the SPF (provided that the server has a default value, they can choose which part to check). This will make the email look like (in perspective)

From: Your server on behalf of the Sending user
To: someone

SPF Sender:, , , , , "".

, , SPF IP- (es) blacklist, spamhaus. , 5.something.

+4

, Sender ID/SPF. , : From: , IP- () SPF DNS.

, MailMessage.Headers, , ( ), SPF, , SPF.

+2

All Articles