PHP 邮件附件电子邮件无效
PHP mailer attachment email not working
我正在使用 phpmailer 并尝试发送带有附件的电子邮件,但电子邮件和附件都无法正常工作(无法发送电子邮件)。
require_once 'phpmailer/class.phpmailer.php';
if (isset($_REQUEST['FindDealer'])) {
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message,
$mail->MsgHTML(file_get_contents('contents . html'));
$email->AddAttachment( $file_to_attach , 'pdf . pdf);
return $email->Send();
exit;
}
请指导我..
您在每一行都使用了变量 $mail
除了以下几行:
$email->AddAttachment( $file_to_attach , 'pdf . pdf);
return $email->Send();
将它们更改为以下内容,它应该可以工作:
$mail->AddAttachment( $file_to_attach , 'pdf . pdf);
return $mail->Send();
编辑:并修复错误(参见语法突出显示):
require_once 'phpmailer/class.phpmailer.php';
if (isset($_REQUEST['FindDealer'])) {
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, ';
$mail->MsgHTML(file_get_contents('contents . html'));
$mail->AddAttachment( $file_to_attach , 'pdf . pdf');
return $mail->Send();
exit;
}
我正在使用 phpmailer 并尝试发送带有附件的电子邮件,但电子邮件和附件都无法正常工作(无法发送电子邮件)。
require_once 'phpmailer/class.phpmailer.php';
if (isset($_REQUEST['FindDealer'])) {
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message,
$mail->MsgHTML(file_get_contents('contents . html'));
$email->AddAttachment( $file_to_attach , 'pdf . pdf);
return $email->Send();
exit;
}
请指导我..
您在每一行都使用了变量 $mail
除了以下几行:
$email->AddAttachment( $file_to_attach , 'pdf . pdf);
return $email->Send();
将它们更改为以下内容,它应该可以工作:
$mail->AddAttachment( $file_to_attach , 'pdf . pdf);
return $mail->Send();
编辑:并修复错误(参见语法突出显示):
require_once 'phpmailer/class.phpmailer.php';
if (isset($_REQUEST['FindDealer'])) {
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, ';
$mail->MsgHTML(file_get_contents('contents . html'));
$mail->AddAttachment( $file_to_attach , 'pdf . pdf');
return $mail->Send();
exit;
}