PHP uses JMail component implementations to send mail

Source: Internet
Author: User
Tags email account

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 (); 

? > 

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.