0
當我點擊提交按鈕xampp - 我需要更改php.ini和sendmail.ini以使用phpMailer發送電子郵件嗎?
應該發送電子郵件給註冊用戶
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 = '[email protected]'; // 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('[email protected]', 'Admin');
$mail->addAddress($_POST['email']); // Add a recipient
//$mail->addReplyTo('[email protected]', 'phpmailer');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
$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
的代碼。我應該這樣做嗎?