loic-sharma / Messages

A Laravel Bundle for the Swiftmailer library
GNU Lesser General Public License v3.0
39 stars 7 forks source link

Doesn't work with attaching files that are remote. #24

Closed jpeterman closed 11 years ago

jpeterman commented 11 years ago

I'm not real familiar with swift mailer, but it looks like this could work based on the swift mailer documentation.

// You can attach files from a URL if allow_url_fopen is on in php.ini $message->attach(Swift_Attachment::fromPath('http://site.tld/logo.png'));

I tried including a file this way, but it didn't work for me. I also tried: $message->attach('http://site.tld/logo.png');

If there is a way to make this work and I'm doing something wrong, please let me know because I'd like to get this working for a project I'm working on.

Thanks!

loic-sharma commented 11 years ago

Try doing this:

Message::send(function($message)
{
    // ...

    $message->swift()->attach(Swift_Attachment::fromPath('http://site.tld/logo.png'));
});
jpeterman commented 11 years ago

Thanks that did work better. It's not loading all the images though. Will it timeout after so many?

I'm also considering uploading to the local server as well and just deleting them after the message is sent. When I played with that it didn't appear that I could delete them inside the send message function. Would that have to happen outside that function?

Thanks. Jason

Sent from my iPhone

On May 15, 2013, at 12:54 PM, "Loic Sharma" notifications@github.com wrote:

Try doing this:

Message::send(function($message) { // ...

$message->swift()->attach(Swift_Attachment::fromPath('http://site.tld/logo.png'));

}); — Reply to this email directly or view it on GitHub.

loic-sharma commented 11 years ago

The timeout depends on the Swift mailer. I'm not sure to be honest.

I don't see why you wouldn't be able to delete an image inside the send message function. All it is is a closure that is passed the message object.

Anyways, I'm going to close this issue off. Feel free to open another one if you need more help.