Sending mail issues. very confusing
- by Dejan.S
Hi my name is what, my name is who.. ops got carried away
Now this might be a serverfault question and a stackoverflow question but I will go with it here because I don't really know the answer.
I been sending mail a lot with asp.net before and never had problems like this before.
I have setup a mail with this following code
var list = new List<string> { "mail", "mail", "mail", "mail" };
var smtp = new SmtpClient("localhost", 25);
var plainText = txtPlain.Text;
var htmlText = Server.HtmlDecode(FCKeditor1.Value);
foreach (var email in list)
{
var message = new MailMessage()
{
From = new MailAddress("my server mail"),
ReplyTo = new MailAddress("mail")
};
var mailMessage = Server.HtmlDecode(FCKeditor1.Value);
message.To.Add(email);
message.Subject = "Hi Enzorit";
message.Body = mailMessage;
message.IsBodyHtml = true;
message.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-2");
var alternateViewHtml = AlternateView.CreateAlternateViewFromString(htmlText, null, MediaTypeNames.Text.Html);
var alternateViewPlainText = AlternateView.CreateAlternateViewFromString(plainText, null, MediaTypeNames.Text.Plain);
message.AlternateViews.Add(alternateViewHtml);
message.AlternateViews.Add(alternateViewPlainText);
smtp.Send(message);
}
now the issue becomes that some email clients get just plain while some get the html.
Like on my hotmail on the computer i get the html but on my iphone i get the plain one.
Why is that?
and like that wasn't enough The mail wont deliver to some mails like any .pl email. Now here is where I am thinking that it might be a reverse DNS setup thing on my windows server 2008 issue + some company mails, it becomes spam, i had same issue with hotmail but that was solved when I added the plain. Anybody have had the problem before?
I am very thankful for any answer I get.. thanks