Let's introduce the format first.
| The code is as follows |
Copy Code |
|
$Jmail = new COM ("Jmail.message"); Instantiate a JMail object
$Jmail->silent=true; When set to True JMail does not prompt for error only returns true and False
$Jmail->logging = false; Whether to turn on the log
$Jmail->charset = "UTF8"; Set string encoding
$Jmail->contenttype = "text/html"; The format of the message is HTML format
$Jmail->mailserverusername = ' Letter mailbox username ';
$Jmail->mailserverpassword = ' letter mail password ';
$Jmail->mailserveraddress= ' SMTP server's address '
$Jmail->fromname = ' sender's name ';
$Jmail->from = ' sender address ';
$Jmail->addrecipient (' addressee address ');
$html = ' email body ';
$Jmail->subject = ' email title ';
$Jmail->body = $html;
$JmailError = $Jmail->send ($Jmail->mailserveraddress);
if ($JmailError) {echo ' sends success ';} |
Example 1
| The code is as follows |
Copy Code |
|
<?php
$jmail = new COM (' Jmail.message ') o& #114; Die (' cannot invoke JMail component ');
$jmail->silent = true; Mask exception Error
$jmail->charset = ' gb2312 '; Otherwise Chinese will be garbled
$jmail->from = ' web535000@163.com '; Here in theory can not be the same as the sender's address, but with 163 of the trial a few times are not good, change
To be the same on the
$jmail->fromname = ' bobotest ';
$jmail->addrecipient (' abc1@163.com '); Can add multiple mail recipients
//$jmail->addrecipient (' abc2@163.com ');
//$jmail->addrecipient (' Abc3@163.com ');
$jmail->subject = ' email test. '
$jmail->body = ' This is test email. '
$jmail->mailserverusername = ' web535000@163.com ';//Letter Email account
$jmail-> Mailserverpassword = ' 123456 '; Account password
try{
$email = $jmail->send (' smtp.163.com ');
if ($email) echo ' sends success ';
else Echo ' sends failed ';
' catch (Exception $e) { Echo $e->getmessage ();
}
? >
|