Laravel mail queue - will attachments go through iron servers?

773 views Asked by At

I'm using Iron.io push queues. Please explain what happens with attachments if I use code like this:

Mail::queue( 'email', array('body' => 'msg body here'), function($message) {
    $message
        ->to('[email protected]')
        ->subject('Subject')
        ->attach(storage_path() . '/file.mp4' );
});

If the file is small ( < 100 KB ) then request to such a page seems to be really quick. If the file is 5MB or so, then the request takes a couple of seconds. Therefore it looks like Laravel serializes attachments, sends them to Iron server, then Iron sends it back to my server and then email is finally sent. Is that true?

That's not what I expect from queues. I expect immediate response to user. I'm totally sure that sync driver is off and app uses iron, since I see messages in iron.io dashboard.

By the way, I'm using ngrok tunelling to work with queues on local dev machine. Maybe thats the cause?

1

There are 1 answers

0
Travis Reeder On

I'm not sure Mail::queue goes out to IronMQ, but if it does, I think you'd want to set it up in a way that the body does not get sent with it.

Instead of queuing the mail, queue up the metadata for the email, eg:

Queue::push(new SendEmail($message, $filepath));

Then when the push comes back to your app, SendMail can call the synchronous send mail:

Mail::send( 'email', array('body' => 'msg body here'), function($message) {
    $message
        ->to('[email protected]')
        ->subject('Subject')
        ->attach(storage_path() . $filepath );
});

I'm not a PHP person so the code may be a bit off, but it should convey the idea.