我的表单的值为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
答案 0 :(得分:0)
附件存放在哪里? 抱歉,我在您的代码中找不到它。 你为什么不把它们放在一个数组中然后循环它们?
类似的东西:
foreach($attachments as $attachment){
$mail->AddAttachment($attachment);
}
如果这不是您需要知道的,请告诉我有关存储此附件的位置的更多信息,我将进一步提供帮助。