Use Opensmtp.net to send messages that require SMTP authentication

Source: Internet
Author: User
Tags http request mail connect require smtpclient firewall
Smtp

1. Introduction

Next week, need to do a send email module, Maito, the weekend at home to do a test, Microsoft, There is System.Web.Mail space in the net1.1, this namespace can send e-mail without SMTP authentication, but now there is very little on the network do not need SMTP authentication, so the class under this namespace should be considered relatively chicken. So find opensmtp.net This open source project, this project admin is the garden inside "My daughter is so beautiful", sincerely thank you.

2. The purpose of this article

This article is not about the use of openmail.net, which is a very formal project with detailed documentation and methods of use. This article focuses on the use of openmail or. NET 2.0 inside the SmtpClient may encounter problems, this problem with your operating environment has a relationship, if you happen to encounter such problems, online related information is relatively small. I'm going to describe the problems I've encountered and the solutions that come out of it.

3. Problems that may be encountered in the use of OpenMail or SmtpClient

1 when sending an email, prompt "Software in your host to discard established connections"

This is the most troublesome problem I have encountered, because he was transferred to 12 last night, I almost did not go crazy. At first I knew it was a firewall problem, but after I shut down the local Windows XP built-in firewall, the problem remained. But whether or not I shut down the firewall, Outlook can receive and send e-mail normally, I use smtp.126.com, I directly Telnet smtp.126.com 25 or in the software tcpclient client = new TcpClient (" Smtp.126.com ", 25); all prompts cannot connect. While Outlook can send mail, I netstat-n that the native's TCP connection to the Smtp.126.com 25 port was also established when Outlook sent e-mail, but why would my software or Telnet not be able to create a connection? How can I get my software and telnet to connect to port 25 on the SMTP server?

2 The first question really let me waste a lot of time, but also wasted n many brain cells, but fortunately finally solved, the second problem is in sending e-mail, the text of the message to create a tangle of problems, this question I see someone online, but very good solution.

4. Steps and methods of problem-solving, as well as lessons learned

1 for the first question, I did make a directional mistake, that is, after I shut down the native firewall, I mistakenly thought that the reason I was unable to connect to the SMTP server properly was because of the firewall on the SMTP service side, and that my local outlook was able to send mail normally, which greatly misled my thinking, My wrong task, Outlook can send, then the data must be able to go out from my local. Errors can only appear on the server side, I suspect that Outlook has a special technology to penetrate the firewall of the SMTP servers, but I looked at the technology through the firewall, if the firewall, the general practice is HttpChannel, in fact, the HTTP request itself can not penetrate the firewall, However, the general firewall does not block the 80-port connection, the Smtp.126.com 80 port is also closed. This thought led me to use a lot of work in the wrong direction.

This morning, I decided to change the idea to see, I turned off the local firewall, or not, and then I saw my macfee, is not this fellow make ghost that, I open Virtusscan console,o,my God, there is a on-delivery e-mail Scanner, I closed it, found or not, I was a bit disappointed, but not reconciled, and then find, and finally found, in Access protection inside, there is a ports to block, which has 25 ports, log files saved in the " AccessProtectionLog.txt ", open the file has many failure records, remove 25 port blocking, prohibit On-delivery e-mail Scanner, problem solving

2 for the second question, only need to change the encoding on it, in the openmail.net set Mailmessage.charset, if in China, set "gb2312" can generally solve this problem

5. Conclusion

After two days of debugging and thinking, solve is not a big problem, but I also learned from a lesson, think about the problem, must be flexible, not too fixed, such as I mistakenly think it is the other side of the firewall problem, and this kind of thinking by my misplaced insist for a long time, In fact, when we can not solve a problem very well, instead of trying our brains, we might as well think about it backwards.



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.