Methods to achieve PHPMailer to send mail Introduction

From:  https://www.php.cn/php-weizijiaocheng-408762.html

 

PHPmailer please download on github, or directly Baidu, it is not difficult, although PHPmailer there a lot of things, but we just need to

PHPMailer.class.php

PHPMailerAutoload.class.php

SMTP.class.php

 

While providing php mail () function, but I would not have not studied, but PHPMailer is a good tool to send email, use is very simple!

<? PHP 

the include ( "class.phpmailer.php" ); 

the include ( "class.smtp.php" ); 

// instantiate 

$ mail = new new PHPMailer (); 

// set smtp parameters 

$ mail -> IsSMTP (); 

mail $ -> SMTPAUTH = to true ; 

$ mail -> SMTPKeepAlive = to true ; 

// $ mail-> SMTPSecure = "SSL"; 

$ mail -> Host = "smtp.163.com" ; 

$ mail -> Port = 25 ; 

// fill in your e-mail account and password 

$ mail -> the Username = "[email protected]" ; 

$ mail-> Password = "*********" ; 

// Set the sender, it is best not fake address 

$ mail -> the From = "[email protected]" ; 

$ mail -> FromName = "Grandpa balcony " ; 

// title, content, and alternate content 

$ mail -> Subject =" 163email " ; 

$ mail -> body =" 163email body " ; 

$ mail -> AltBody =" 163email !!! plain text "; // if HTML message format is not supported, then replace the plain text mode mail 

$ mail -> the WordWrap = 50; // set the number of characters per line messages 

// $ mail-> MsgHTML ($ body); 

// set the reply address 

$ mail - > AddReplyTo ( "[email protected]", "YY" );

// add attachments, accessories and here scripts are located in the same directory, otherwise fill in the full path

//$mail->AddAttachment("attachment.zip "); 

// set the e-mail recipient's name and e-mail 

$ mail -> AddAddress (" [email protected] "," FirstName LastName " ); 

// use the HTML format E-mail 

$ mail -> IsHTML ( to true ); 

// send a message through the send method, transmission processing according to the results accordingly 

IF (! $ mail -> send ()) { 

echo "transmission failure:." $ mail -> the ErrorInfo; 

} the else { 

echo 'message has been sent successfully " ; 

}

 >?

 

Guess you like

Origin www.cnblogs.com/init-007/p/11449208.html