Comparison of several methods of sending letters by ASP program

Source: Internet
Author: User
Tags format comparison log mail
Comparison | program

  First, JMAIL3 and previous versions use the Jmail.smtpmail letter, the specific code is as follows:

<%
Set JMail = Server.CreateObject ("JMail. SmtpMail ")" Creates a JMail object
Jmail.silent = True ' JMail does not throw an exception error and returns a value of false and True
Jmail.logging = True ' Enable use of logs
JMail. Charset = "GB2312" The code for the message text is Simplified Chinese
JMail. ContentType = "text/html" The format of the message is HTML
JMail. ServerAddress = "server address" ' Sending a message
JMail. AddRecipient Email ' recipient of email '
JMail. SenderName = "SenderName" ' Mail sender's name
JMail. Sender = "Email address" ' e-mail addresses of senders
JMail. Priority = 1 ' Mail emergency program, 1 for fastest, 5 for slowest, 3 for default value
JMail. Subject = "Mail Subject" ' Title of Message
JMail. BODY = contents of mail body
JMail. ADDRECIPIENTBCC Email ' BCC Recipient's address
JMail. ADDRECIPIENTCC email ' cc's address
JMail. Execute () ' Send mail
JMail. Close ' Closes the mail object
%>

There are still a number of programs that use this method to send letters, and there is a big flaw in this is that the letter was sent using the server local SMTP service and did not pass any SMTP authentication, and the letter failed if the server set up the need to use authentication. Now because of anti-spam needs, more and more servers began to focus on this aspect of the setup problem, if you use this method to send a message suddenly abnormal, it may be the server limit anonymous letter, the above code will not function properly.

This method is not recommended, but there are many ASP programs that use this method, may still work, but it is difficult to ensure that the future will continue to be normal, and some mail server will reject the method sent letters, so if possible, try not to use this way.

  Second, to talk about Microsoft's own CDONTS components of the way to send a letter:

<%
Set Cdomail = Server.CreateObject ("CDONTS. NewMail ")" Create mail object
Cdomail. Subject = "Mail Subject" ' Message headers
Cdomail. from = "Sender ' s Mail" ' sender's address
Cdomail. to = "Email would from" ' Recipient's address
Cdomail. BODY = contents of mail body
Cdomail. Send ' performs sending
%>

This method of sending mail is the simplest, but also bring certain problems, that is very few servers will open this service, even if opened, but also because there is no authentication information, sent letters will be rejected by many servers, strongly recommended not to use.

  Third, the W3 Jmail4.3 component has redesigned its internal structure -- Use the Message object instead of the original single object jmail.smtpmail send mail, and add the settings that require authentication, and the object's properties have changed a lot more than before, causing the program to be completely rewritten, and the new version of the letter example looks like this:

<%
Set JMail = Server.CreateObject ("JMail. Message ")" To create an object to send mail
Jmail.silent = True ' Mask exception error, return False to true two value J
Jmail.logging = True ' Enable mail logging
JMail. Charset = "GB2312" ' Text encoding for the message is GB
JMail. ContentType = "text/html" The format of the message is HTML format
JMail. AddRecipient Email ' Address of Mail Recipient
JMail. from = "Email from to Sender" ' E-mail address of sender
JMail. Mailserverusername = "UserName of email" ' User name required to log on to the mail server
JMail. Mailserverpassword = "Password of email" ' Password required to log in to the mail server
JMail. Subject = "Mail Subject" ' Title of Message
JMail. BODY = contents of mail body
JMail. Send ("server address") ' Perform mail delivery (via mail server addresses)
JMail. Close () ' Closes object
%>

Using this code to send a letter, is currently the most stable, but also the most applicable to the letter method, we recommend the use of JMail letter to the customer, use this method to send a letter.



Related Article

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.