-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Hi,
I understand that queueing works by serializing and unserializing whole swift mailer message object.
If the message object is set for posting into long future and in the meantime with some upgrade the swiftmailer message object changes, then unserializing will fail.
It would be much safer to store email as a binary text without unserializing - separate headers and body. Unserializing is not only error prone, but also stores bunch of useless object data (with swift message are also serialized other related in-memory swift objects).
We have customers who wants to send email reminder for example next year. With serializing/unserializing we could not do any safe upgrade of swift mailer until last email posted.
Unlike swift mailer, PHP mailer exposes two methods PreSend and PostSend. First one allows fetching separate headers & body as a binary text suitable to async post:
if($mail->PreSend()){
// no serialized objects, just binary texts:
$modelMail->header = $mail->getMIMEHeader();
$modelMail->body = $mail->getMIMEBody();
$modelMail->save();
}
Then next year without any dependency on mailer related objects we can just pull data from DB & post:
$modelMail->findOne(123);
$mail->setMIMEHeader($modelMail->header);
$mail->setMIMEBody($modelMail->body);
if($mail->PostSend()){
++$success;
}
That's why we cannot use swiftmailer, it's not suitable for queueing unlike PHPMailer - there is no method to store separately headers & body as a binary text in swift mailer.