邮件中含三个附件$mail->AddAttachment($a[0], $a[0]); // 添加附件,并指定名称
$mail->AddAttachment($a[1], $a[1]); // 添加附件,并指定名称
$mail->AddAttachment($a[2], $a[2]); // 添加附件,并指定名称为什么邮件中附件只有一个? 高手请指点
$mail->AddAttachment($a[1], $a[1]); // 添加附件,并指定名称
$mail->AddAttachment($a[2], $a[2]); // 添加附件,并指定名称为什么邮件中附件只有一个? 高手请指点
我在发邮件时,是将邮件的附件放入一个数组中,然后循环填入邮件正文以下。确认邮件内容无误,再发送。
public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
try {
if ( !@is_file($path) ) {//这是惟一的判断
throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
}
$filename = basename($path);
if ( $name == '' ) {
$name = $filename;
} $this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'attachment',
7 => 0
); } catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
if ( $e->getCode() == self::STOP_CRITICAL ) {
return false;
}
}
return true;
}
public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream')