我正在尝试制作一个发送pdf的答案,我已经尝试过了,一切都很顺利,但我希望答案(回复(只得到pdf,而不是表单输入的数据。
我的问题是,当你回答时,是否有可能只收到pdf文件,而不需要获取我在表格中输入的数据?
1-我收到表单数据2-填写表格的人收到一个pdf/img,但表格中输入的数据没有到达
<?php
$nombre = $_POST['name'];
$email = $_POST['email'];
$telefono = $_POST['phone'];
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;
require './Exception.php';
require './PHPMailer.php';
require './SMTP.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '*****@******'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'tls '; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('******@***', 'Página web' );
$mail->addReplyTo($email);
$mail->addCC($email);
$mail->addBCC($email);
// Attachments
$mail->addAttachment('atencion-memoria.pdf');
// Add attachments
$message = "<html><body>";
$message .= "<table align='center' width='100%' border='0' cellpadding='0' cellspacing='0' style='max-width:650px; background-color:#fff; font-family:Verdana, Geneva, sans-serif;'>";
$message .= "<tbody>
<tr style='border-radius:10px'>
<th style='color:white;background:linear-gradient(50deg,rgb(15,90,224) 0%,rgb(15,90,224) 0%,rgb(116,0,186) 100%,rgb(116,0,186) 100%);text-align:center;padding:10px'>Nombres</th>
<td style='padding:10px'>
<p style='font-size:15px;font-family:Century Gothic;margin:2px'>".$nombre."</p>
</td>
</tr>
<tr style='border-radius:10px'>
<th style='color:white;background:linear-gradient(50deg,rgb(15,90,224) 0%,rgb(15,90,224) 0%,rgb(116,0,186) 100%,rgb(116,0,186) 100%);text-align:center;padding:10px'>Email</th>
<td style='padding:10px'>
<p style='font-size:15px;font-family:Century Gothic;margin:2px'>".$email."</p>
</td>
</tr>
<tr style='border-radius:10px'>
<th style='color:white;background:linear-gradient(50deg,rgb(15,90,224) 0%,rgb(15,90,224) 0%,rgb(116,0,186) 100%,rgb(116,0,186) 100%);text-align:center;padding:10px'>Teléfono</th>
<td style='padding:10px'>
<p style='font-size:15px;font-family:Century Gothic;margin:2px'>".$telefono."</p>
</td>
</tr>
</tbody>";
$message .= "</table>";
$message .= "</body></html>";
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Pagina de Bienestar ';
$mail->AltBody = 'mensaje alternativo 11';
$mail->Body = $message ;
$mail->send();
echo "<script language='javascript'>
window.location.href = '*****';
</script>";
} catch (Exception $e) {
echo "Error: {$mail->ErrorInfo}";
}
当然!
只是不要在$mail->Body = $message;
中分配表格,也不会将表格添加到电子邮件中:
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Pagina de Bienestar ';
$mail->AltBody = 'mensaje alternativo 11';
$mail->Body = $message ;
// to
$mail->isHTML(false); // Set email format to HTML
$mail->Subject = 'Pagina de Bienestar ';
$mail->Body = 'mensaje alternativo 11';