0
フォームデータを表形式でメールに送信する必要があります。このために私はPHPMailerを使用しています。ユーザーが選択した値を表示しようとすると、配列として表示されるだけです。誰かが私にこのコードの何が間違っているかを見つけるのを助けることができますか?PHPメーラを使用してフォームデータをメールに送信できません
以下はここでPHPの一部
$Favorite_Drink = $_POST['Favorite_Drink'];
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'pass'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'User');
$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
//$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
$mail->Subject = 'Here is the subject';
//$mail->Body = "Name of patient is ";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true);
$mail->Subject = ' Test';
$mail->Body = <<<EOF
<html><body>
<br>
<table rules="all" style="border-color: #666;" cellpadding="10">
<tr style='background: #eee;'>
<td>Favorite_Drink </td>
<td> $Favorite_Drink</td>
</tr>
</table>
</body>
</html>
EOF;
//Altbody is used to display plain text message for those email viewers which are not HTML compatible
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
}
申し訳ありませんが動作しません! – phpLover
この回答は正しいです - 配列を直接印刷することはできません、あなたはそれぞれの要素を処理する必要があります。私はphpLoverが少し難しくする必要があると思う... – Synchro