Sending email asynchronously with PHP and RabbitMQ - what do you put on the queue?

624 views
Skip to first unread message

Dave Hollingworth

unread,
May 26, 2016, 2:15:53 PM5/26/16
to rabbitmq-users
I want to use PHPMailer and RabbitMQ to send emails asynchronously. I'm new to RabbitMQ and I've done the tutorials, but when I actually get around to putting a message on the queue, I'm not sure what to put on there.

I want to save an email to send later. So what do I put on the queue? An array containing the subject, body, recipients etc.? A serialized PHPMailer object? I've tried the latter and it works ok, but as I'm new to RabbitMQ I'm not sure if I'm going about it the right way.

Does anyone have any experience of using RabbitMQ to send emails (ideally with PHPMailer)? Is there a recommendation for what to put on the queue?

Any help for a newbie is greatly appreciated!

Michael Klishin

unread,
May 26, 2016, 4:51:23 PM5/26/16
to rabbitm...@googlegroups.com
RabbitMQ doesn't care what the payload is, it is treated as an opaque collection of bytes.

Using a language-specific format such as serialised PHP objects may be convenient but has serious downsides:

 * You will likely be limited to a single language for all services
 * Future PHP versions may or may not be able to interoperate with the one you use today

Using a reasonably popular language-neutral serialisation format (JSON, Message Pack, Protocol Buffers are popular choices)
is a better idea in my opinion.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Dave Hollingworth

unread,
May 27, 2016, 4:17:09 AM5/27/16
to rabbitmq-users
Ah ok, makes sense. I wasn't aware of Message Pack or Protocol Buffers. Message Pack looks the most interesting for what I'm doing, I'll try using that. Thanks for your help!
Reply all
Reply to author
Forward
0 new messages