0

phpMailerを使用して簡単なお問い合わせフォームをデザインしています。データはPHPに正しく渡されますが、電子メールは送信されません。エラー情報を確認してみましたが、空です。何かご意見は?前もって感謝します!

<?php

    require_once('email/mail/class.phpmailer.php');

    $email_to = 'myEmail';
    $email_subject = 'Contact form';    

    $fname = $_POST['firstname'];
    $lname = $_POST['lastname'];
    $email = $_POST['email'];
    $dob = $_POST['dob'];
    $subject = $_POST['subject'];
    $comments = $_POST['comments'];

    $mailer = new PHPMailer(true);
    $mailer->Host = '**********';
    $mailer->Username = '********';
    $mailer->Password = '*********';
    $mailer->SMTPAuth = true;
    $mailer->AddAddress($email_to);
    $mailer->SMTPDebug = false;
    $mailer->IsSMTP();
    $mailer->FromName = 'Contact Page';
    $mailer->From = "**********";
    $mailer->Sender = '**********';
    $mailer->Subject = $email_subject;
    $mailer->Body = "
        Source: Contact Page
        Name: ".$fname. " ".$lname."
        Email: ".$email."
        Date of Birth: ".$dob."
        Subject: ".$subject."
        Comments: ".$comments;

    echo "Data received";

    if(!$mailer->Send()) {
        echo 'Message was not sent.';
        echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent.';
    }

?>

出力は次のとおりです。

Data receivedMessage was not sent.Mailer error: 

の出力print_r($mailer)

PHPMailer Object ( 
    [Priority] => 3 
    [CharSet] => iso-8859-1 
    [ContentType] => text/plain 
    [Encoding] => 8bit 
    [ErrorInfo] => 
    [From] => contact@blah.com 
    [FromName] => Contact Page 
    [Sender] => contact@blah.com 
    [Subject] => Contact form 
    [Body] => 
        Source: blah 
        Name: Derp McDerpson 
        Email: derpallday@gmail.com 
        Date of Birth: 1/1/2000 
        Subject: The things! 
        Comments: fix them 
    [AltBody] => 
    [WordWrap] => 0 
    [Mailer] => smtp 
    [Sendmail] => /usr/sbin/sendmail 
    [PluginDir] => 
    [Version] => 1.73 
    [ConfirmReadingTo] => 
    [Hostname] => 
    [Host] => mail.authsmtp.com 
    [Port] => 25 
    [Helo] => 
    [SMTPAuth] => 1 
    [Username] => blah 
    [Password] => blah 
    [Timeout] => 10 
    [SMTPDebug] => 
    [SMTPKeepAlive] => 
    [smtp] => 
    [to] => Array ( 
        [0] => Array ( 
            [0] => blah@blah.com 
            [1] => blah 
        ) 
    ) 
    [cc] => Array ( ) 
    [bcc] => Array ( ) 
    [ReplyTo] => Array ( ) 
    [attachment] => Array ( ) 
    [CustomHeader] => Array ( ) 
    [message_type] => 
    [boundary] => Array ( ) 
    [language] => Array ( ) 
    [error_count] => 0 
    [LE] => 
)
4

3 に答える 3

0

実際の送信部分が欠落していると思います:$ mailer-> Send(); それを追加して実行してみてください

于 2012-06-18T14:22:16.927 に答える
0

解決しました。「from」と「sender」に間違った値を使用しようとしましたが、サーバーが正しく設定されていませんでした。ご意見をお寄せいただきありがとうございます。

于 2012-06-20T13:01:19.057 に答える
-1

名"。$_POST['fname']。"company"。$_POST['company']。"Email"。$_POST['email']。"Telephone"。$_POST['telelphone']。"コメント"。$_POST['comments']。"";$ headers =" MIME-Version ":1.0 \ r \ n"; $ hearder = "Content-type:text / html; charest = iso-8859-1 \ r \ n "; $headers。="FROM:"。$ _POST['email']。"\r \ n "; mail($ to、$ subject、$ body、$ headers); echo '

于 2013-07-20T17:58:52.450 に答える