我想知道如何在PHP中發送郵件。我已經嘗試了PHP郵件程序,但它不起作用。我們可以從本地主機發送郵件嗎?如何使用wampserver在php中發送郵件?
<?php
require_once 'class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->AddAddress("[email protected]@gmail.com");
$mailer->Subject = "Student Registration";
$mailer->From = "[email protected]";
$mailer->FromName = "course registration system";
// $mailer->AddBCC("[email protected]", "Registeration");
$mailer->Body ="You have registered";
if($mailer->Send()){
echo "Sent";
}
else
echo 'Mailer Error: ' . $mail->ErrorInfo;
echo "Not Sent";
?>
你需要比「它不工作」更精確一點。怎麼了?顯示什麼錯誤?本地郵件服務器的日誌中有什麼? – Synchro
[配置WAMP服務器發送電子郵件]的可能重複(http://stackoverflow.com/questions/5773288/configure-wamp-server-to-send-email) – anshabhi