使用 Tmail & 转发邮件ActionMailer::ARMMailer
我正在编写一个 rake 任务来使用 Tmail 来检查我们的一个邮箱中的传入邮件。对于某些邮件,我只想将它们转发到另一个地址。但我不确定最好的方法是什么。
我们网站的常规邮件是使用 ARMailer 发送的:我调用 Mailer.deliver_ ,邮件是从模板生成的,并放入我们的电子邮件表中,该表由实际发送邮件的 ARMailer 访问。所以,我的 Mailer 类的类定义如下所示:
class Mailer < ActionMailer::ARMailer
#list of methods here, one per email type
end
所以,我想要做的是,在我的脚本中,当我有一个代表传入邮件的 Tmail 对象时,生成一封新邮件以粘贴到我们的邮件队列中基本上是 Tmail 邮件,转发到新地址。我不确定最好的方法是什么。我可以建立一个新的多部分邮件,从收到的 Tmail 对象中复制正文、主题和字段,但这似乎有点笨拙,应该有更好的方法。
我可以做类似
newmail = Mailer.create_forward(my_tmail_object) 的事情吗 newmail.to = "[电子邮件受保护]" 新邮件.投递
??
Mailer/ARMMailer 没有 create_forward 方法,但它与我所追求的类似。欢迎任何建议!谢谢
I'm writing a rake task to go through one of our mailboxes of incoming mail, using Tmail. For certain mails, i just want to forward them on to another address. I'm not sure what the best way to do that is though.
Our regular mails for the website are sent out using ARMailer: i call Mailer.deliver_ and the mail is generated from a template and put into our Email table, which in accessed by ARMailer which actually sends the mails out. So, the class definition of my Mailer class looks like this:
class Mailer < ActionMailer::ARMailer
#list of methods here, one per email type
end
So, what i want to do, is, in my script when i have a Tmail object representing the incoming mail, is to generate a new mail to stick into our mail queue which is basically the Tmail mail, forwarded onto a new address. I'm not sure what the best way to do that is. I could build up a new multipart mail copying the body, subject and from field from the recieved Tmail object, but that seems like it might be a bit clumsy, and that there should be a nicer way.
Can i do something like
newmail = Mailer.create_forward(my_tmail_object)
newmail.to = "[email protected]"
newmail.deliver
??
Mailer/ARMailer doesn't have the create_forward method but it's something like that that i'm after. Any advice welcome! thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论