【发布时间】:2017-08-21 23:57:47
【问题描述】:
当我点击提交按钮时
if (isset($_POST['btn_signup'])) {...
它应该向注册用户发送一封电子邮件
require './PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myEmail@gmail.com'; // SMTP username
$mail->Password = 'myPassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('myEmail@gmail.com', 'Admin');
$mail->addAddress($_POST['email']); // Add a recipient
//$mail->addReplyTo('info@phpmailer.com', 'phpmailer');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
$mail->isHTML(true); // Set email format to HTML
$bodyContent = '<h1>How to Send Email using PHP in Localhost</h1>';
$bodyContent .= '<p>This is the HTML email sent from localhost using PHP</p>';
$mail->Subject = 'Email from Localhost';
$mail->Body = $bodyContent;
但它不起作用。我发现网上有人更改了一些php.ini 和sendmail.ini 代码。我应该这样做吗?
【问题讨论】:
标签: php xampp smtp localhost phpmailer