这是我的网站 - > nodeiterator.pl
为什么我发送电子邮件没有 $ mail-> addAttachment($ file); 我做接收电子邮件但是......我添加 $ mail-> addAttachment($ file); 我不要在我的邮箱上接收电子邮件,即使我收到了消息...我在这里缺少什么?我的目的是将表单结果发送到我的邮箱 WITH 附件文件......
下面这是我负责发送消息的PHP脚本:
<?php
$msg = "";
use PHPMailer\PHPMailer\PHPMailer;
include_once "phpmailer/PHPMailer.php";
include_once "phpmailer/Exception.php";
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$nazwisko = $_POST['nazwisko'];
$imie = $_POST['imie'];
if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") {
$file = "attachment/" . basename($_FILES['attachment']['name']);
move_uploaded_file($_FILES['attachment']['tmp_name'], $file);
} else
$file = "";
$mail = new PHPMailer();
$message = "
<html>
<head>
<meta charset=\"utf-8\">
</head>
<style type='text/css'>
body {font-family:sans-serif; color:#222; padding:20px;}
div {margin-bottom:10px;}
.msg-title {margin-top:30px;}
table {
border-collapse:collapse;
}
</style>
<body>
<table border=\"2\">
<tr>
<td>Nazwisko osoby ubezpiecząjacej :</td>
<td>$nazwisko</td>
</tr>
</table>
</body>
</html>";
$mail->addAddress('piterdeja@gmail.com');
$mail->setFrom($email);
$mail->isHTML(true);
$mail->Body = $message;
$mail->addAttachment($file);
$mail->AllowEmpty = true;
if ($mail->send())
$msg = "Your email has been sent, thank you!";
else
$msg = "Please try again!";
unlink($file);
}
?>