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.