Home > Article > Backend Development > Method 2 of sending emails in PHP 2. (SMTP transfer SMTP class call to send)_PHP tutorial
[html]
require_once("email2.php");//This is method 2 of sending emails in php. (SMTP transmission SMTP class)
/**
*Server information
*/
$MailServer = 'smtp.163.com'; //SMTP server
$MailPort = '25'; //SMTP server port number Default 25
$MailId = 'anheng123@163.com'; //Server email account
$MailPw = 'xxxxxxxxxxx'; // Server email password
/**
*Client information
*/
$Title = 'System developer reports error message'; //Email title
$bt="sadfsadf";
$_POST['url']="afasdfasfasfsaf";
$_POST['lianxi']="12312412";
$_POST['xiangxi']="What I said is confusing but I feel like I have changed it";
$td=$subject.'
'.'Title:'.$bt.'
'.'url:'.$_POST['url'].'
'.'Contact Phone:'.$_POST['lianxi'].'
'.'Details:'.$_POST['xiangxi'];
$Content = $td; //Email content
$email = www.2cto.com target recipient email
$smtp = new smtp($MailServer,$MailPort,true,$MailId,$MailPw);
$smtp->debug = false;
if($smtp->sendmail($email,$MailId, $Title, $Content, "HTML")){
echo 'Email sent successfully'; //return result
} else {
echo 'Failed to send email'; //$succeed = 0;
}
?>
Author: Vericlongmore