7

私は自分のphpメーラーにアドレスへの返信を追加しようとしていますが、それは「私」から送信され、私のアドレスに返信します。

私が間違っていることについて何か考えはありますか?$mail->AddReplyToを追加しました。Webフォームの送信者に返信してほしい。

$name = $_POST['name'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$message = $_POST['message'];

$body             = file_get_contents('phpmailer/contents.html');
$body             = eregi_replace("[\]",'',$body);
$body             = eregi_replace("<name>", $name,$body);
$body             = eregi_replace("<telephone>", $telephone, $body);
$body             = eregi_replace("<email>", $email, $body);
$body             = eregi_replace("<message>", $message, $body);




$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.gmail.com"; // SMTP server
                    // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "xxx@xxx.net";  // GMAIL username
$mail->Password   = "xxxxx"; 

$mail->AddReplyTo($email, $name);


$address = "xxxx.net";

$mail->AddAddress($address, "Contact form");

$mail->Subject    = " Contact Form";
4

1 に答える 1

2

試してみるべきことは、変数$email$name変数が正しく渡されていることを確認することです (それらをエコーアウトするデバッグステートメントを追加してください)。それを行ったかどうか、またはフォームが投稿されたかどうかを確認しているかどうかはわかりません。しかし、それはステップ 1 になります。

PHPMailer と GMail を使用した私の作業から、それらはうまく機能しません。代わりに、phpGMailerスクリプトを試すことをお勧めします。GMail に最適です。それでも問題が解決しないかどうかを確認してください。

アップデート

ReplyTo考えてみると、GMail アカウントがそのアカウントの認証を有効にしない限り、GMailはアドレスの変更を許可しないと思います。これについて 100% 確信があるわけではありませんが、Web インターフェースでは不可能であることはわかっています。

オフトピック

減価償却されているので使用は避けたいと思いeregi_replaceます。代わりに使用preg_replaceします。コードを更新できるように、更新されたバージョンを次に示します。

$body             = file_get_contents('phpmailer/contents.html');
$body             = preg_replace("~[\]~",'',$body);
$body             = preg_replace("~<name>~i", $name,$body);
$body             = preg_replace("~<telephone>~i", $telephone, $body);
$body             = preg_replace("~<email>~i", $email, $body);
$body             = preg_replace("~<message>~i", $message, $body);
于 2010-10-21T15:19:55.110 に答える