douji0588 2011-02-25 13:00
浏览 46
已采纳

转发Zend_Mail_Message

Is there an easy way how I could forward Zend_Mail_Message to another recipient?

I would like just add the recipients address, "FWD:" to subject and forward existing Zend_Mail_Message as attachment or inline message.

  • 写回答

1条回答 默认 最新

  • dongwei7913 2011-02-26 17:20
    关注

    If you meant something like

    $oldMail = new Zend_Mail_Storage_Imap();
    $mail = new Zend_Mail($oldMail);
    $mail->addTo($oneEmail);
    $mail->send();
    

    Then no, it's not possible. But you can always manually change the subject, add recipient's, and create an attachment from your old message:

    //connect with imap
    $oldMail = new Zend_Mail_Storage_Imap(array(
                                         'host'     => 'example.com',
                                         'user'     => 'test',
                                         'password' => 'test'));
    $newBody = $_POST['body']; //new body text
    //If you want to download previous message
    $messageNum = 8; //you have to know message number
    $oldMessage = $mail->getMessage($messageNum); //in order to get it
    
    $mail = new Zend_Mail();
    $mail->addTo($oldMail->getEmail())
         ->setSubject('RE: ' . $message->subject)
         ->setBodyText($newBody);
    
    //create an attachment
    $attachment = $mail->createAttachment($message->getContent());
    $attachment->type = 'text/plain';
    $attachment->filename = 'RE.txt';
    $message->addAttachment($attachment);
    
    $mail->addTo($email);
    $mail->send();
    

    Additionally this may be helpful

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计