SmtpClient发送电子邮件至垃圾级 [英] SmtpClient sends email to junk
问题描述
我试着用SmtpClient.Send()从C#发送电子邮件,但它总是转到垃圾邮件箱。如果我从Outlook发送它工作正常。反正是有解决这个问题?有人告诉我修改的电子邮件标题,但我不知道怎么办。
在此先感谢。
这里是我的代码
SmtpClient客户端=新SmtpClient();
client.Host =smtp.server.com;
client.Credentials =新System.Net.NetworkCredential(用户,密码);
MailAddress MAILFROM =新的MailAddress(mymail@server.com);
MailAddress MAILTO =新的MailAddress(yourmail@server.com);
MailAddress mailReply =新的MailAddress(mymail@server.com);
消息MAILMESSAGE新= MAILMESSAGE(MAILFROM,MAILTO);
message.Body =这是一个测试邮件。
message.Subject =测试消息;
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
client.Send(消息);
A)的代码示例实际上并未使用的mailReply地址。
b),当你发送一个更现实的消息问题可能会消失。如果没有,那么你将不得不找出为什么该消息被标记的垃圾,从spambox钓鱼的消息来看,在标题或类似的东西。
I tried to send email from c# using SmtpClient.Send() but it always goes to the junk box. It works fine if I send it from Outlook. Is there anyway to solve this? Someone told me to modify the email header but I don't know how. Thanks in advance. Here is my code
SmtpClient client = new SmtpClient();
client.Host = "smtp.server.com";
client.Credentials = new System.Net.NetworkCredential("user", "password");
MailAddress mailFrom = new MailAddress("mymail@server.com");
MailAddress mailTo = new MailAddress("yourmail@server.com");
MailAddress mailReply = new MailAddress("mymail@server.com");
MailMessage message = new MailMessage(mailFrom, mailTo);
message.Body = "This is a test message.";
message.Subject = "test message";
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
client.Send(message);
a) The code sample doesn't actually use the mailReply address.
b) The problem will probably disappear when you send a more realistic message. If it doesn't then you will have to find out why the message is being marked junk, fishing a message from the spambox and looking at the headers or something like that.
这篇关于SmtpClient发送电子邮件至垃圾级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!