我有一个PHP页面可以发送带有附件的电子邮件(职业表格)。 我已经在( Windows Chrome 浏览器”上正确接收了带有附件的电子邮件。
当我使用 Android移动版-chrome 浏览器时,附件未打开文件大小:0字节 (注意:从手机收到带有附件的邮件-但不支持附件)
谢谢。
HTML:
<form type="submit" enctype="multipart/form-data">
<input type="file" name="attachment">
<button name="submit" type="submit">SEND</button>
</form>
PHP:
if(isset($_POST['submit'])){
extract($_POST);
$to="example@email.com";
$msg="email body";
require 'include/PHPMailer_master/src/PHPMailer.php';
require 'include/PHPMailer_master/src/SMTP.php';
require 'include/PHPMailer_master/src/Exception.php';
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.siteprotect.com';
$mail->SMTPAuth = true;
$mail->Username = 'example@email.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('example@email.com');
$mail->addAddress($to);
$mail->addAttachment($_FILES['attachment']['tmp_name'],
$_FILES['attachment']['name'] );
$mail->isHTML(true);
$mail->Subject = 'RESUME - Sales Engineer (from website careers page)';
$mail->Body = $msg;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo '<script>alert("Message has been sent");</script>';
} catch (Exception $e) {
echo '<script>alert("Message not sent");</script>';
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
}