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] =>
)