我想使用php邮件程序(class.phpmailer.php)在gmail帐户中发送PDF附件?
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->From = '';
$mail->FromName = '';
$mail->Subject = '';
$MESSAGE_BODY = "Name: ".$username." "."\r\n";
$MESSAGE_BODY .= "Contact No.: ".$contact." "."\r\n";
$MESSAGE_BODY .= "Message: ".$message." "."\r\n";
$mail->Body = $MESSAGE_BODY;
$mail->AddAddress( '' );
$mail->AddAttachment($_FILES['file']['tmp_name'],
$_FILES['file']['username']);
if ($mail->Send())
{
echo "Mail Sent";
}
else
{
echo "Could not send mail";
}
?>
答案 0 :(得分:0)
PHPMailer类只允许您使用Google的SMTP服务器。 你应该用普通的方式发送它。使用$ mail-&gt; AddAttachment($ filePath); 如果您有任何具体问题,请更具体。
答案 1 :(得分:0)
无法发送消息.Mailer错误:SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting