Zend framework ZF邮件附件问题
为什么我收到相同的附件两次与此代码Zend framework ZF邮件附件问题,zend-framework,email,Zend Framework,Email,为什么我收到相同的附件两次与此代码 $mailer = new Zend_Mail('UTF-8'); $mailer->setFrom($group_email,$group_name); $mailer->setSubject($title); $mailer->setBodyHtml($full); $fileContents = file_get_contents('test.jpg'); $attachment = $mailer->createA
$mailer = new Zend_Mail('UTF-8');
$mailer->setFrom($group_email,$group_name);
$mailer->setSubject($title);
$mailer->setBodyHtml($full);
$fileContents = file_get_contents('test.jpg');
$attachment = $mailer->createAttachment($fileContents);
$attachment->filename = "test.jpg";
$mailer->addAttachment($attachment);
//get all subscribers
$i=0;
foreach ($subscribers->getGroupUsers($group_id) as $sub){
if ($i==0){
$mailer->addTo($sub->email);
}
else {
$mailer->addBcc($sub->email);
}
$i++;
}
$mailer->send();
看起来这是因为您正在使用
createAttachment
和addAttachment
。请确保您遵守了有关如何执行此操作的说明
例如:
$mail = new Zend_Mail();
// build message...
$mail->createAttachment($someBinaryString);
$mail->createAttachment($myImage,
'image/gif',
Zend_Mime::DISPOSITION_INLINE,
Zend_Mime::ENCODING_8BIT);
问题就在这方面
$mailer->addAttachment($attachment);
没有它,它就会工作。我不知道这一点,因为对我来说调用addAttachment方法似乎是合乎逻辑的:P
这是一个适合我的方法,试图发送一份简历,在zend中有attachmnet
$mail = new Zend_Mail ();
$mail->setBodyHTML ( stripslashes ($message) );
// add attachment
$fileContents = file_get_contents($attachemnet);
$resume = $mail->createAttachment($fileContents);
$resume->filename = $EmployeeDeatils['resume'];
//$mail->createAttachment($attachemnet);
$mail->setFrom ( $mail_template ['from_email'], $mail_template ['from_caption'] );
$mail->addTo ( $clientemail, $employee_name );
$mail->setSubject ($subject );
try {
$mail->send ();
} catch ( Exception $e ) {
$this->_helper->errorlog ( " Send mail to member with activation link : " . $e->getMessage () );
}
你的回答对我帮助很大