STMP sends an email as a solution to spam.

Source: Internet
Author: User
Tags mailmessage smtpclient microsoft outlook

STMP sends an email as a solution to spam.

Used yesterday.. Net sends an email to its QQ mailbox through smtp, but after sending the email successfully, it does not prompt the mailbox to receive a new email, and no new email is added to the inbox.

This makes me feel strange, so I think whether it is filtered out as spam. So I click the recycle bin to see if it is. QQ mail is filtered and processed as spam.

So I immediately searched online and finally found the method.

Problem:

The recipient's email server determines that emails sent by software with unknown origins may be considered as spam and directly filtered out. This is the filter condition of the recipient, the fact that we cannot change.

Solution:

1. Use the system.net. mail class of the custom authentication mechanism to send messages. Do not use the system. web. mail class to send emails. Generally, emails sent by the latter are treated as spam, which is related to the verification mechanism.

2. Declare the email address and header information (msg. Headers. Add ("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869"); Put on the outlook vest)

3. in special cases, some servers may still be treated as spam after you have put on a valid vest, such as Netease, because there may be some sensitive words in your email content, or illegal information.

 

Email sending code:

/// <Summary> /// send the email /// </summary> /// <param name = "Subject"> topic </param> /// <param name = "Body"> email content </param> /// <param name = "To"> recipient's email address </param> /// <param name = "MailFrom"> sender </param> /// <param name = "MailFromName"> name of the sender </param> /// <param name = "MailDomain"> server address </param>/ param> /// <param name = "MailServerUserName"> user name and password </param> /// <param name = "MailServerPassWord"> password </param> /// <returns> </returns> public bool Send (string Subject, string Body, string To, string MailFrom, string MailFromName, string MailDomain, string MailServerUserName, string MailServerPassWord) {try {MailMessage msg = new MailMessage (); msg. from = new MailAddress (MailFrom, MailFromName); msg. to. add (new MailAddress (To, To); msg. subject = Subject; msg. body = Body; msg. isBodyHtml = true; msg. priority = MailPriority. normal; msg. subjectEncoding = System. text. encoding. UTF8; msg. bodyEncoding = System. text. encoding. UTF8; // key code not used as spam -- Begin msg. headers. add ("X-Priority", "3"); msg. headers. add ("X-MSMail-Priority", "Normal"); msg. headers. add ("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869"); // This article sends emails in the name of outlook and will not be treated as spam msg. headers. add ("X-MimeOLE", "Produced By Microsoft MimeOLE V6.00.2900.2869"); msg. headers. add ("returnreceept", "1"); // key code not considered as spam -- End SmtpClient client = new SmtpClient (MailDomain); client. useDefaultCredentials = false; client. credentials = new NetworkCredential (MailServerUserName, MailServerPassWord); // account password client. deliveryMethod = SmtpDeliveryMethod. network; client. send (msg); return true;} catch {return false ;}}

Then try to send an email to the QQ mailbox, which can be received in the 126 mailbox.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.