Record your own process of using SMTP and JMail

zhaozj2021-02-16  108

These days have been organized for some interesting things, and many interesting things have been discovered. The issue sent by this message I used it for a few days. I checked a lot of information on the Internet and asked many friends to succeed. There are also many places worth noting, the total summarizes:

1. The system.web.mail class comes with .NET can be verified. Specific reference code below. 2.Webform's email program Turn off the firewall and some anti-virus software when using and debugging, and does not show 100% of the problem and other strange problems; in this case, WinForm can be sent normally However, anti-virus software is to detect (the situation when I test). 3. If you want to send an email, you must have a SMTP server, you can apply for a username and password until 163, just like the application mailbox, but if you send the mail from the message from the message from 163. Caom. 4. Or build a mail server yourself, I use the Webeeasymail Enterprise Edition, then you can build any domain name in this server, the process of the from address is set to you here, even if this domain name does not exist or not You apply. WebEasymail helps write as long as you can access the Internet, you don't need a domain name, but you must have domain names.

The following is posted on two codes: 1. Use JMail sent, use 163 user name BMONKEY 1024 and password 123456. MessageClass email = new MessageClass (); email.Logging = true; email.Silent = true; email.MailServerUserName = "bmonkey1024"; email.MailServerPassWord = "123456"; email.From = "bmonkey1024@163.com"; email. Subject = "testjmail"; email.body = "test jmail send mail"; email.charset = "gb2312"; email.conteType = "text / html"; email.addrecipient ("bmonkey@tom.com", ", ""); email.send ("SMTP.163.com", false; email.close ();

2. Use System.Web.mail to send mail, create a new user BMONKEY, password 123456, and domain name Testmymail in WebEasymail. MailMessage myMessage = new MailMessage (); myMessage.To = "bmonkey@tom.com"; myMessage.From = "bmonkey@testmymail.com"; myMessage.Subject = "testWebMail"; myMessage.BodyFormat = MailFormat.Text; SmtpMail. SMTPSERVER = "127.0.0.1"; mymessage.body = "I finally sent success!"; Mymessage.fields.add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate," 1 "); // Basic AuthenticationmyMessage.fields.add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "bmonkey"); // set your username heremyMessage.fields.Add ("http: // schema. Microsoft.com/cdo/configuration/sendpassword "," 123456 "); // set your password Heresmtpmail.send (MyMessage); Finally, pay attention to the verification method of System.Web.mail in the second segment code. ^ _ ^, This is seen on the blog of Joycode, there is no MSDN.

转载请注明原文地址:https://www.9cbs.com/read-13472.html

New Post(0)