I need to send form data to mail in tabular format. for this i'm using using PHPMailer. when I am trying to display values that are selected by user it only display as array. can somebody help me to find what is wrong in this code?
Below is the part of HTML
<input type="checkbox" name="Favorite_Drink[]" value="Vodka">Vodka
<input type="checkbox" name="Favorite_Drink[]" value="Vodka">Vodka
<input type="checkbox" name="Favorite_Drink[]" value="Bear">Bear
Here is PHP part
$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> echo implode(" ",$Favorite_Drink)."<br>";</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';
}
}
}