PHP Phpmail the effect of sending mail

Source: Internet
Author: User
Tags word wrap

Method One:

/*                                                            ,         &NB Sp         * Email original smtp_mail                                              ,         &NB sp; * @param $emailAddress                                               *         @param $e Mailtitle Title theme                               &N Bsp                   * @param $emailContent Mail content       &NBSP ;                              ,         &N bsp; * @param $type types                           &NB Sp                                 * @re Turn Bollean                               &NBS P                               */  &N Bsp                          ,         &NB Sp                          ,         &NB Sp;public function SmtpMail ($emailAddress, $emailTitle, $emailContent, $type = ' html ') {                                       ,         &N Bsp                                 //import Class                                   nbsp                                  &nbs P Yii::import (' Ext.communication.PHPMailer ');                                  &nbs P $mail = new Phpmailer ();                          ,         &NB Sp                    $mail->charset = "Utf-8";    //Set code                 &NBSp                      $mail->encoding = "base64";    //Set code                             &NB Sp        $mail->issmtp ();    //use SMTP                                                $mail->host = ' smtp.qq.com ';    //such as: smtp.163.com;mail.tsingfeng.com        $mail->smtpauth = true;    //authentication function                             &NB Sp            $mail->username = '[email protected]‘;    User name must fill in the sender's email address $mail->password = ' Mimazheli '; Password $mail->from = '[email protected]‘;    Set the sender's e-mail address $mail->fromname = ' Liuyang ';                                          Set the sender's name $arr _email=explode (' | ', $emailAddress);    foreach ($arr _email as $val) $mail->addaddress ($val, "); Set the address of the pickup (bulk multiple) $mail->addreplyto ('[email protected]', ' Liuyang ');//reply person                        $mail->wordwrap = 30}    //50 word wrap                             &NB Sp              $mail->subject = $emailTitle;                          ,         &NB Sp                                  &NBS P                          ,         &NB Sp                      if ($mail->send ()) return true;                          ,         &NB Sp              return False                          

}

Method Two:

Require ("class.phpmailer.php"); The downloaded file must be placed in the directory where the file is located
$mail = new Phpmailer (); Set up a mail sending class
$mail->charset = "UTF-8"; Character
$mail->encoding = "base64"; Encoding method
$mail->issmtp (); Send using SMTP mode
$mail->host = "smtp.qq.com";//For example: smtp.163.com;mail.tsingfeng.com use QQ mailbox service as Send mail
$mail->smtpauth = true; Enable the SMTP authentication feature
$mail->username = ' [email protected] '; Sender's email address (please fill in the full email address)
$mail->password = "duxinlihanjinshan131425"; Sender's mailbox password
$mail->from = ' [email protected] '; Set the sender's e-mail address
$mail->fromname = "Dunueli";//Set the sender's name
$mail->addreplyto (' [email protected] ', ' Dunueli ');//reply person
$address = $email;
$mail->port=25;
$mail->addaddress ("$address", "" ");//recipient address, can be replaced by any email to receive mail, the format is addaddress (" Recipient Email "," Recipient Name ")
$mail->subject = "user account activation";
$mail->body = "Dear". $username. " :<br/> Thank you for registering a new account at my station. <br/> Please click on the link to activate your account. <br/><a href= ' http://localhost/register/active.php?verify= '. $token. "' target= ' _blank ' >http:// Localhost/register/active.php?verify= ". $token."; </a><br/> If the above link cannot be clicked, please copy it into your browser's address bar to access it, the link is valid within 24 hours. <br/> If this activation request is not issued by you, please ignore this email. <br/><p style= ' text-align:right ' >--------hellwoeba.com </p> "; Additional information can be omitted//e-mail content


if (! $mail->send ())
{
echo "message failed to send. <p> ";
echo "Error Reason:". $mail->errorinfo;
Exit

}else{
echo "Mail sent successfully! Please go to your designated mailbox to activate your account";
}

PHP Phpmail the effect of sending mail

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.