1
私は次のコードを持っています。 「正常に送信されました」というメッセージが返されますが、指定されたGmailでメールは受信されません。このコードは正しいのですか?PHPのメール機能は、希望のemail_idにメールを送信しません
<?php
require("mailer/PHPMailerAutoload.php");
require("mailer/class.smtp.php");
require("mailer/class.phpmailer.php");
$name=$_POST['Your_Name'];
$email=$_POST['Your_Email'];
$message=$_POST['Your_Msg'];
echo $name ;
$mail = new PHPMailer();
// set mailer to use SMTP
//$mail->IsSMTP();
// As this email.php script lives on the same server as our email server
// we are setting the HOST to localhost
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->Port = "465";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "[email protected]"; // SMTP password
// $email is the user's email address the specified
// on our contact us page. We set this variable at
// the top of this page with:
// $email = $_REQUEST['email'] ;
$mail->From = $email;
// below we want to set the email address we will be sending our email to.
$mail->AddAddress("[email protected]", "Mandar");
// set word wrap to 50 characters
$mail->WordWrap = 50;
// set email format to HTML
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website!";
// $message is the user's message they typed in
// on our contact us page. We set this variable at
// the top of this page with:
// $message = $_REQUEST['message'] ;
$mail->Body = $message;
$mail->AltBody ="Name : {$name}\n\nEmail : {$email}\n\nMessage : {$message}";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
else
{
echo "Thank you for contacting us. We will be in touch with you very soon.";
}
?>
このコードには問題がありますか、別の方法を試す必要がありますか?
一部のメールホストには、いくつかの種類のセキュリティフィルタがあります。 gmail、ymailなどでプライベートなメールのホストやチェックを試してみることをお勧めします。 –
'$ mail-> Port =" 465 "; // 8025,587,25も使用できます。 SSLにポート465を使用してください。ポートが見つかりませんでした – prasanth
[SMTP Connect()の複製が失敗しました。メッセージは送信されませんでした。メールエラー:SMTP Connect()が失敗しました](http://stackoverflow.com/questions/18496650/smtp-connect-failed-message-was-not-sent-mailer-error-smtp-connect-failed ) –