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

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
roscoe
Forum Commoner
Posts: 85
Joined: Tue Aug 05, 2003 10:24 am
Location: essex uk

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

Post 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:
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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 ?
roscoe
Forum Commoner
Posts: 85
Joined: Tue Aug 05, 2003 10:24 am
Location: essex uk

Post by roscoe »

Ah would that work then??
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

No - i guess you could add your own plugin for that ?
roscoe
Forum Commoner
Posts: 85
Joined: Tue Aug 05, 2003 10:24 am
Location: essex uk

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You can embed images manually into the HTML: http://www.swiftmailer.org/wikidocs/v3/ ... ing_images
roscoe
Forum Commoner
Posts: 85
Joined: Tue Aug 05, 2003 10:24 am
Location: essex uk

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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");
roscoe
Forum Commoner
Posts: 85
Joined: Tue Aug 05, 2003 10:24 am
Location: essex uk

Post 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
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

oh...only if they're absolute paths.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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")));
Post Reply