In Asp programs, most people use Jmail to send emails, mainly because most virtual hosts support them, while others support them less.
Here is an example code for sending emails from Jmail:
If you try it on your own machine, please download Jmail.dll. After downloading and decompressing, double-click Setup.bat to complete the installation!
The code copy is as follows:
<%
Onerrorresumenext
DimJMail, contentId
SetJMail=Server.CreateObject("JMail.Message")
JMail.Charset="gb2312"''''''Mail character set, default is "US-ASCII"
''''JMail.ISOEncodeHeaders=False'''' Whether to perform ISO encoding, default is True
''''Sender information (can be assigned as variables)
JMail.From="[email protected]"'''''Sender Address
JMail.FromName="XiaoZ.Com"'''''Sender name
JMail.Subject="Mail Subject"'''''Mail Subject
''''Authentication
JMail.MailServerUserName="myusername"'''''Authenticated Username
JMail.MailServerPassword="mypassword"'''''Authentication Password
''''' Set priority, ranging from 1 to 5, the larger the priority, the higher the priority, 3 is normal
JMail.Priority=3
JMail.AddHeader"Originating-IP",Request.ServerVariables("REMOTE_ADDR")
''''Add to join a recipient [Variable email: Recipient address] You can add multiple repetitions in the same statement.
JMail.AddRecipient("[email protected]")
''''Add attachment [Variable filename: the absolute address of the attachment file, ensuring that the user IUSR_machine name has access permission]
'''[The parameter setting is True or False as Inline]
''''contentId=JMail.AddAttachment(Server.MapPath("jmail.asp"),True)
''''Email body (HTML (note the way to link attachments in the letter))
JMail.HTMLBody="<html><head><METAcontent=zh-cnhttp-equiv=Content-Language><metahttp-equiv=""Content-Type""content=""text/html;charset=gb2312""><styletype=text/css>A:link{FONT-SIZE:9pt;TEXT-DECORATION:none;color:#000000}A:visited{FONT-S IZE:9pt;TEXT-DECORATION:none;color:#666666}A:hover{COLOR:#ff6600;FONT-SIZE:9pt;TEXT-DECORATION:underline}BODY{FONT-SIZE:9pt}--></style></head><body><fontcolor=red>Email text</font><br><fontcolor=green>Email text</font><br><b>Email text</b></body></html>"
''''Mail body (text part)
JMail.Body="Our emails are in HTML format, but your email viewing software may not support them... Email text, Email text, Email text"
''''Send【Call format: objJMail.Send([username:password@]SMTPServerAddress[:Port])]