Many times, errors occur when sending emails using jmail. Common causes include:
1. The email sending server address is incorrect. If the email address is sent in 163, the server address should be smtp.163.com.
2. Many mail servers need to verify the mailbox Login Name (for example: laifangsong@163.com) and password (123456), if both are not submitted, the send will also fail.
3. The sender's email address and the sender's login name are inconsistent.
The followingCodeIt has been debugged in ASP.
< %
Dim Nreturnvalue ' Sending Function
Nreturnvalue = Sendmail_jmail ( " Mail.qcmw.com " , " Laifangsong # qcmw.com " , " Qingcheng WAP automatic website construction system " , " Laifangsong # qcmw.com " , " #123456 # " , " Laifangsong # 126.com " , " Registration successful prompt " , " You registered on our website! " )
Select Case Nreturnvalue
Case 0
Response. Write " Email sent successfully! "
Case 1
Response. Write " An error occurred while creating the jmail component! "
Case 2
Response. Write " Failed to send email! "
End Select
' Jmail mail (4.4)
' Component download: http://www.52z.com/Down/3525.html
' Parameters: sending SMTP server, Sender's email address, sender's name, Sender's login name, Sender's login password, recipient's email address, email title, and email content
Function Sendmail_jmail (s_smtpserver, s_frommail, s_fromname, s_mailserverusername, s_mailserverpassword, s_toemail, s_subject, s_body)
On Error Resume Next
Set Jmail = Server. Createobject ( " Jmail. Message " ) ' Create an email recipient
If Err. Number <> 0 Then
Sendmail_jmail = 1
Exit Function
End If
Jmail. Silent = True ' Block exception errors. The values false and true are returned.
Jmail. Logging = False ' Enable Mail Log
Jmail. charset = " Gb2312 " ' The text of the email is encoded as Chinese.
Jmail. isoencodeheaders = False ' Prevents garbled email titles
Jmail. contenttype = " Text/html " ' The email is in HTML format.
Jmail. addrecipient s_toemail ' Email Recipient address
Jmail. From = S_frommail ' The sender's E-MAIL address
Jmail. fromname = S_fromname ' Sender name
Jmail. mailserverusername = S_mailserverusername ' Username required to log on to the email server
Jmail. mailserverpassword = S_mailserverpassword ' Password required to log on to the email server
Jmail. Subject = S_subject ' Email title
Jmail. Body = S_body ' Email content
Jmail. Priority = 1 ' Urgent emailProgram, 1 is the fastest, 5 is the slowest, and 3 is the default value
Jmail. Send (s_smtpserver) ' Execute email sending (via email server address)
Jmail. Close () ' Close object
If Jmail. errorcode <> 0 Then
Sendmail_jmail = 2
Else
Sendmail_jmail = 0
End If
End Function
' SMTP mail server sending component in IIS
Function Sendmail_iissmtp (s_frommail, s_toemail, s_subject, s_body)
Set Cdomail = Server. Createobject ( " Cdonts. newmail " ) ' Create email object
Cdomail. Subject = S_subject ' Email Subject
Cdomail. From = S_frommail ' Sender address
Cdomail. = S_toemail ' Recipient address
Cdomail. Body = S_body ' Email content
Cdomail. Send ' Execute sending
End Function
%>