php – 傳送電子郵件從localhost與gmail(windows)
我想使用我的localhost的mail()函式.我有WAMP安裝和一個Gmail帳戶.我知道SMTP的SMTP是smtp.gmail.com,埠是465.我需要在WAMP中配置,所以我可以使用mail()函式?
Ayush的答案非常有用,低於簡單的方法
1)下載PHPMailer/PHPMailer" rel="nofollow,noindex" target="_blank">PHPMailer
2)提取到php專案中的資料夾,並將其重新命名為phpmailer
3)建立gmail-sample.php並貼上以下程式碼:
<?php require("phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); // ---------- adjust these lines --------------------------------------- $mail->Username = "[email protected]"; // your GMail user name $mail->Password = "your-gmail-password"; $mail->AddAddress("[email protected]"); // recipients email $mail->FromName = "your name"; // readable name $mail->Subject = "Subject title"; $mail->Body= "Here is the message you want to send to your friend."; //----------------------------------------------------------------------- $mail->Host = "ssl://smtp.gmail.com"; // GMail $mail->Port = 465; $mail->IsSMTP(); // use SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->From = $mail->Username; if(!$mail->Send()) echo "Mailer Error: " . $mail->ErrorInfo; else echo "Message has been sent"; ?>
4)從瀏覽器傳送郵件(例如http://localhost/your-project/gmail-sample.php ).
http://stackoverflow.com/questions/4982821/send-email-from-localhost-with-gmailwindows