These two days because of the company's website Mail is not sent out, and then studied the ASP site to send mail and the ASP. e-mail sent to the code, the problems encountered here to record.
1. First say send mail in ASP.
Just at the beginning only 126 mailbox can send mail, and then other 163, Sina and other hair not out, later depressed for a long time to know the mailbox SMTP and POP3 service default is not open, need to manually open to send mail. For example, Sina Mailbox Open SMTP service as follows:
Other mailboxes are similar to the ability to send mail, sending the following message code:
<summary>//C # Send mail///</summary> public void Showsendemail () {String fromemail = " [Email protected] "; Sender e-mail address string emailsmtphost = "smtp.126.com"; Mailbox SMTP server, used to send mail string emailSubject = "email Subject"; Message subject String emailbody = "
2, and then use ASP to send mail, now tested there are two ways to send mail success
The first way code is as follows:
<%
'define the Send Message methodfunction Showsendemail Set objmail= Server.CreateObject ("CDO. Message") Set Objcdo= Server.CreateObject ("CDO. Configuration") Objcdo.fields ("http://schemas.microsoft.com/cdo/configuration/sendusing") =2Objcdo.fields ("Http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.126.com" 'Mail ServerObjcdo.fields ("Http://schemas.microsoft.com/cdo/configuration/smtpserverport") = - 'mail server default portObjcdo.fields ("Http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") =Ten 'Timeout SettingsObjcdo.fields ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =1Objcdo.fields ("Http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]"'Email address for sending mailObjcdo.fields ("Http://schemas.microsoft.com/cdo/configuration/sendpassword") ="*****" 'Email PasswordobjCDO.Fields.Update Set objmail.configuration=OBJCDO Objmail.from="[email protected]" 'sender, this is consistent with the email address aboveObjmail.subject ="Email Subject" 'message HeaderObjmail.to ="[email protected]" 'RecipientObjmail.htmlbody ="Hello, test mail. " 'send content. objmail.send Set objmail=Nothing Set Objcdosyscon=NothingEnd Functionshowsendemail'Call method, send Message
%>
The second call to the JMail component to send the message, call this component to send the message,
It is important to note that the JMail component must be installed before the message can be sent successfully (never installed before, sending always reported missing object error)
JMail Component Download paths are: http://download.csdn.net/detail/tandaxia/8598007
<% ' Define Send mail method sub showjmail on Error Resume Next Dim jmail Set jmail = Server.CreateObject ("Jmail.message" ) jmail.silent=true jmail.logging = true jmail.charset = "gb2312" jmail.mailserverusername = "[Email Protected] " ' mailbox login user name Jmail.mailserverpassword =" ************* " ' mailbox password jmail.contenttype = ' text/ HTML " jmail.priority = 1 jmail.from =" [email protected] " sender e-mail address jmail.fromname =" Xmtan " ' Sender's name can be the same as the sender's e-mail address jmail.addrecipient "[email protected] ' recipient email address jmail.subject = ' email Subject ' ' Mail subject Jmail.body = "
ASP and ASP. E-Mail notes