1

我有一个具有价值的表格count。我想发送带有附件的邮件,附件是count值的多次。实际上我想通过if声明发送附件检查一些因素,所以我该怎么做,请任何人帮助我吗?我的代码在这里:

<?php
echo $count;
require_once 'session.php';
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = file_get_contents('mail.html');
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("lipsa.auroin@gmail.com","First Last");
$mail->SetFrom('lipsa.auroin@gmail.com', 'First Last');
$mail->AddReplyTo("lipsa.auroin@gmail.com","First Last");
$email=$_POST['email2'];
$addresses = explode(',', $email);
foreach ($addresses as $address){
    $address = trim($address);
    $mail->AddAddress($address);
}
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$mail->AddAttachment("pdf/report.pdf");
$mail->AddAttachment("pdf/template.pdf");
if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
    echo "Message sent!";
}
?>

我的count变量值从 1 到 n

4

1 回答 1

0

附件存储在哪里?抱歉,我在您的代码中找不到它。你为什么不把它们放在一个数组中然后循环它们呢?

就像是:

foreach($attachments as $attachment){
  $mail->AddAttachment($attachment);
}

如果这不是您需要知道的,请告诉我更多有关此附件存储位置的信息,我会进一步提供帮助。

于 2013-02-11T09:41:09.223 回答