Page 1 of 1

emailing a web page like m/s explorer to a list

Posted: Tue Aug 07, 2007 6:39 am
by roscoe
I wonder if Swiftmailer could email a webpage (with ALL images etc embedded) as ms explorer does, but modified to cover multiple addresses?

This would be simple if I could point swiftmailer at the content of a webpage and let it pick up the whole thing and email it to my list. Is it possible?

:roll:

Posted: Tue Aug 07, 2007 9:04 am
by anjanesh
You mean to say something like

Code: Select all

$message = new Swift_Message("Some subject", "http://devnetwork.net", "text/html");
would load the contents of http://devnetwork.net of into the body ?

Posted: Tue Aug 07, 2007 9:59 am
by roscoe
Ah would that work then??

Posted: Tue Aug 07, 2007 10:03 am
by anjanesh
No - i guess you could add your own plugin for that ?

Posted: Tue Aug 07, 2007 10:06 am
by roscoe
anjanesh wrote:No - i guess you could add your own plugin for that ?
Hmm, where should I start? any clues, I have no idea, hence the question. It seems to me this would be the best idea to send formatted HTML emails though?

Posted: Tue Aug 07, 2007 11:42 am
by Chris Corbyn
You can embed images manually into the HTML: http://www.swiftmailer.org/wikidocs/v3/ ... ing_images

Posted: Tue Aug 07, 2007 12:16 pm
by roscoe
but anjanesh idea is a great one. Is it possible to do by pointing swift at a webpage to collect the whole content as ms explorer does?

Posted: Tue Aug 07, 2007 12:57 pm
by Chris Corbyn
roscoe wrote:but anjanesh idea is a great one. Is it possible to do by pointing swift at a webpage to collect the whole content as ms explorer does?
Yes, it's possible but I haven't written the code to do it. It's a pretty complex thing to do ;)

Posted: Tue Aug 07, 2007 9:11 pm
by anjanesh
roscoe - as an alternative to a plugin solution, simply do

Code: Select all

$body = file_get_contents($url);
if ($body === FALSE) die();
$message = new Swift_Message("Some subject", $body, "text/html");

Posted: Wed Aug 08, 2007 10:01 am
by roscoe
anjanesh wrote:roscoe - as an alternative to a plugin solution, simply do

Code: Select all

$body = file_get_contents($url);
if ($body === FALSE) die();
$message = new Swift_Message("Some subject", $body, "text/html");
Would that embed all images too??? :o

Posted: Wed Aug 08, 2007 10:03 am
by anjanesh
oh...only if they're absolute paths.

Posted: Wed Aug 08, 2007 10:29 am
by Chris Corbyn
anjanesh wrote:oh...only if they're absolute paths.
It won't "embed" the images, it will still try to download them in the mail client. You need to use Swift's image embedding stuff to embed images ;)

Posted: Sun Sep 09, 2007 8:44 am
by anjanesh
Someone seems to have written a function addImage (Bonus section) with a complete tutorial at cakephp !
http://bakery.cakephp.org/articles/view ... t-tutorial
One thing that is nice with Swift Mailer, is a function called addImage, it embeds an image into the body of the email to display inline.

Posted: Sun Sep 09, 2007 10:42 am
by Chris Corbyn
anjanesh wrote:Someone seems to have written a function addImage (Bonus section) with a complete tutorial at cakephp !
http://bakery.cakephp.org/articles/view ... t-tutorial
One thing that is nice with Swift Mailer, is a function called addImage, it embeds an image into the body of the email to display inline.
That was old code from version 2.x of Swift Mailer. I wrote the addImage() method in version 2. In version 3 the functionality still exists, you just need to use Swift_Message_Image instead:

Code: Select all

$message->attach(new Swift_Message_Image(new Swift_File("/path/to/image.jpg")));