I might be just blind (very possible!) but i can't find any information on here/Google anywhere that helps me out at all :(
First up, below is the code i'm using to send the email message:
MailMessage newMM = new MailMessage();
newMM.To.Add(new MailAddress(userEmail));
newMM.From = new MailAddress(getFrom, getFromName);
newMM.IsBodyHtml = true;
newMM.Subject = userSubject;
newMM.Body = userHTML;
if (chkEncoding.Checked)
{
newMM.BodyEncoding = System.Text.Encoding.UTF8;
newMM.SubjectEncoding = System.Text.Encoding.UTF8;
}
NetworkCredential basicAuthenticationInfo = new NetworkCredential(mUsername, mPassword);
SmtpClient smtp = new SmtpClient(mServer);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = basicAuthenticationInfo;
smtp.Send(newMM);
Which sends fine, and does UTF8 fine when enabled etc... however in the resulting email i get this (UTF8 or not):
...
MIME-Version: 1.0
From: "The name i want"
<[email protected]>
To: [email protected]
...
And this is from checking the files in MSSMTP Queue folder, so it seems to me its .NET adding the line break in or MSSMTP doing it when it receives the email.
Anyone come across this before? or have ideas? :)
The reason this is important to fix is because Declude is saying that the from address doesn't match and adds spam weight which i can see via the headers:
X-RBL-Warning: FROMNOMATCH: Env sender ([email protected]) From: ("The name i want") mismatch.
...
X-Declude-Tests: ... FROMNOMATCH [2] ...
So i imagine other spam filters will also have a whinge about it.
EDIT:
For reference; All emails look perfectly fine in all email clients, this is purely a header rendering/spam processor problem.
If someone has a little spare time, could they possibly send a message using .NET and check the raw headers (unedited and unparsed by email client) and let me know? i'll keep on trucking for now :)
EDIT2:
I have created a basic SMTP server in .NET using sockets, basic replies (220's, 250's, 354's etc) and used the code to connect to it and send... and the problem occurs, so this is definitely at the code/.NET side of things and not MS-SMTP.
I have also created a brand new .NET 4.0 windows application, added a button and put in this code (note i added the using System.Net.Mail; to the top as well but nothing else from a blank new windows application):
private void button1_Click(object sender, EventArgs e)
{
MailMessage newMM = new MailMessage();
newMM.To.Add(new MailAddress("[email protected]"));
newMM.From = new MailAddress("[email protected]", "Happy As'Larry");
newMM.IsBodyHtml = true;
newMM.Subject = "My Subject";
newMM.Body = "My HTML";
SmtpClient smtp = new SmtpClient("localhost");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(newMM);
}
Please note this is NOT edited in any way... as its local to a testing SMTP output application there is no need for verification so its exactly as it is above.
My SMTP application uses a TcpListener and Socket objects from System.Net.Sockets and just outputs all remote data to a simple text box, it parses a string for the command buffer so it can actually reply and get to the DATA command to check what .NET is sending however :)
Output is here:
EHLO WhiteDragon-PC
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
MIME-Version: 1.0
From: "Happy As'Larry"
<from[email protected]>
To: [email protected]
Date: 28 Feb 2011 19:00:19 +1100
Subject: My Subject
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
My HTML
.
So with 2 fully new applications, with very basic code in each i still get the problem!
Is this a .NET 4.0 bug? if anyone wants the SMTP code i'll paste that too if you want to check this thing out.