C # Set the timed sending mailbox,

Source: Internet
Author: User

C # Set the timed sending mailbox,

Today, we temporarily maintained the Demo of timed email sending by our colleagues.

 

Originally, Netease 163 mailbox was used for timed sending, but the mailbox may not receive emails.

Today, I changed it to a QQ mailbox, and found that the QQ mailbox is relatively stable and there are basically no missed emails.

 

However, some configuration problems occurred during the process of modification, and some time was recorded.

 

1. Change the smtp server first. The QQ mailbox is smtp.qq.com.

 

2. Use your qq account to log on to your mailbox. In Settings> account, enable pop3/stmp settings. (If your mailbox is just activated, you need to wait for 14 days to use this function)

 

3. An authorization code must be generated after the function is enabled. (in a third-party client, QQ mail only supports the account + authorization code for security purposes)

Specific settings visible: http://service.mail.qq.com/cgi-bin/help? Subtype = 1 & no = 1001256 & id = 28

 

4. NetEase used to use port 25 without ssl encryption. When it arrived at the QQ mailbox, it would not work. Must use ssl-encrypted port 465/587

 

You can use the instance Send method of the SmtpClient class to Send emails. The MailAddress class and MailMessage class are used to encapsulate the information to be sent.

 

Problems:

(1) The command order is incorrect. Server Response: Error: need EHLO and AUTH first!

Solution: Enable the smtp service, as shown in.

 

(2) The password here uses the authorization code.

 

(3) syntax errors exist in parameters or variables. Server Response: mail from address must be same as authorization user

You must use an authorization code instead of an email password to log on to your QQ mailbox.

 

 

Unsolved problems:

<1>. I do not know why port 465 is used. The operation times out. Port 587 can always be sent normally.

Do you know why ?? Please advise.

 

<2>. The current Code uses Timer to match the time of the configuration file every second. If the time is the same, the code for sending the email is executed.

I feel a little troublesome. Next I plan to use quartz.net to execute the scheduled task. It should be more appropriate.

 

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.