PHP Mailer编译并存储消息以供以后发送 [英] PHP Mailer compile and store message for later sending

查看:85
本文介绍了PHP Mailer编译并存储消息以供以后发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以将消息作为草稿编译并存储在PHP邮件程序中,然后再发送每条消息吗?

Can we compile and store messages as a draft in PHP mailer and then later on send each message?

推荐答案

使用PHPMailer可以 进行此操作.在使用所有通常需要发送消息的内容配置PHPMailer实例之后,请不要调用send()-而是调用preSend()(用于构造消息),然后使用getSentMIMEMessage()获取消息内容,例如

It is possible to do this with PHPMailer. After configuring the PHPMailer instance with everything you'd normally need to send the message, do not call send() - instead call preSend() (which constructs the message) and then get the message content using getSentMIMEMessage(), e.g.

$mail->preSend();
$message = $mail->getSentMIMEMessage();

$message将包含完整的RFC822消息,您可以将其粘贴在数据库,队列或以后发送的任何内容中.要稍后进行实际发送,可以使用 PHPMailer的SMTP类直接.要查看如何驱动该类,请查看 PHPMailer的smtpSend() 函数.

$message will then contain a complete RFC822 message which you can stick in a database, queue or whatever to send later. To do the actual sending later, you could make use of PHPMailer's SMTP class directly. To see how to drive that class, look at PHPMailer's smtpSend() function.

这篇关于PHP Mailer编译并存储消息以供以后发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆