Thinkphp send mail phpmailer

// official mailing
public phpMail function () {
$ = Data Request () -> param (); // receiving post, get value
Vendor ( "PHPMailer.phpmailer");
Vendor ( "PHPMailer.class_smtp");
// include_once "phpmailer.phpmailer.php";
// include_once "phpmailer.class.smtp.php";
// include_once "Exception.php";
// get the contents of an external file
$ mail = new new \ PHPMailer ();
$ mailcontent = "file link you need to: <a href='".$data['content']."'>" $ data [ ' content'] "</a> click on the link to download:"; //. message content
//
// set parameters smtp
$ mail-> IsSMTP ();
$ mail-> the Charset = 'UTF-. 8';
$ mail-> = SMTPAUTH to true;
$ mail-> = SMTPKeepAlive to true;
$ mail->= Host "ssl: //smtp.126.com";
$ mail-> Port = 465;
// Fill in your email account and password
mail- $> the Username = "[email protected]";
$ mail-> Password = "ceshi190050"; # note here is that I want to fill out an authorization code to open in the above-mentioned SMTP NetEase mailbox, the mailbox logon password can not fill Oh.
// set the sender, it is best not fake address
$ mail-> the From = "[email protected]";
$ mail-> FromName = "zhangsan"; // sender's user name
$ mail-> Subject = $ data [ 'title']; // message header
$ mail-> AltBody = $ mailcontent; // message content
$ mail-> the WordWrap = 50; // Word wrap sET
$ mail-> MsgHTML ($ mailcontent);
// set the reply address
mail- $> AddReplyTo ( "[email protected]", "ceshi90050");
// set the mailbox of the recipient and the message name
$ mail-> AddAddress ($ data [ 'toemail'], $ data [ 'toemail'] ); // recipient mailboxes and user name
// use the HTML format to send mail
$ mail-> IsHTML (true);




$ msg = "Sorry, mailing Failure Check the mailbox fill is wrong!.";
} the else {
$ Status = 1;
$ msg = "email sent successfully";
}
return JSONP ([ 'Status' => $ Status, 'MSG' => $ MSG]);
}

Guess you like

Origin www.cnblogs.com/Mr-zhangwenqiang/p/11936037.html