[英]Send attachment with PHPMailer
I have a little function, which supposed to be sending an email with the submitted image as attachment. 我有一个小功能,它应该发送一封电子邮件,其中包含提交的图像作为附件。 I receive the email, that's okay, but the attachment is missing.
我收到了电子邮件,没关系,但附件丢失了。 The PHPMailer isn't trowing any errors, so I don't know what could be the problem.
PHPMailer没有任何错误,所以我不知道可能是什么问题。
This is the actual code: 这是实际的代码:
if(isset($_FILES['submitimg']['name'])){
$messageBody .= "<p>Bla bla bla:</p>";
$messageBody .= "<p>Bla name: ".$_POST['submitname']."</p>";
$messageBody .= "<p>Bla email: ".$_POST['submitemail']."</p>";
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->setFrom('blab@blabla.com', 'Bla bla');
$mail->addAddress($adminEmail, $adminName);
$mail->Subject = 'New blabla';
$mail->Body = $messageBody;
$fileName = $_FILES['submitimg']['name'];
$filePath = $_FILES['submitimg']['tmpname'];
$mail->addAttachment($filePath, $fileName);
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
Can someone help me out, please? 有人可以帮帮我吗? :)
:)
Thank you very much! 非常感谢你!
Okay, I found the solution. 好的,我找到了解决方案。 It was a simple typo:
这是一个简单的错字:
$filePath = $_FILES['submitimg']['tmp_name'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.