Page 1 of 1

A bit of advice on embedding

Posted: Mon Jul 02, 2007 9:56 am
by roscoe
Having built a "timer" to send all 2500 emails at intervals with attachments, I have now been given the dubious honor of embedding PDF files into each email.

Is this possible through Swiftmailer or would I have to transfer the stuff to HTML or word to embed the document into the email?

Thanks

Re: A bit of advice on embedding

Posted: Mon Jul 02, 2007 11:29 am
by Chris Corbyn
roscoe wrote:Having built a "timer" to send all 2500 emails at intervals with attachments, I have now been given the dubious honor of embedding PDF files into each email.

Is this possible through Swiftmailer or would I have to transfer the stuff to HTML or word to embed the document into the email?

Thanks
It's possible, but I'm wondering if a simple attachment will suffice? Embedding a PDF may not work on all mail clients.

I'll have to refresh my memory on the format you need for embedded files without HTML...

Posted: Tue Jul 03, 2007 2:18 am
by roscoe
I have been told that it may be in other formats like word. Is Word more practical?

They insist the want to embed the info and not have to open it, but they will want it in either PDF or Word

Posted: Tue Jul 03, 2007 5:44 am
by Chris Corbyn
roscoe wrote:I have been told that it may be in other formats like word. Is Word more practical?

They insist the want to embed the info and not have to open it, but they will want it in either PDF or Word
They can insist but they can't have ;) Theres no way email will ever allow documents to be opened and displayed inline with any amount of reliabilty. Imagine if you sent this to hotmail for example. The hotmail web page would then need include an embedded PDF, you rely on a PDF reader being installed which allows embedding in web pages too. Many mail clients (pine anyone?) won't handle it neither. I'm not sure even Thunderbird would open a PDF or word document inline sorry. You can certainly embed the file with <embed> like you like in HTML, but don't expect it to be reliable.

If I were you I'd be talking your client out of this idea because it's going to cause you a lot of headaches when he/she realises it doesn't work as expected ;)

Posted: Tue Jul 03, 2007 6:14 am
by roscoe
Is there any way I can embed any pre designed document or say an image to cover all those who can receive embedded docs? Most are not Hotmail or webmail email addresses

Posted: Tue Jul 03, 2007 12:49 pm
by Chris Corbyn
If you can get it to work in your web browser using HTML, then try putting that HTML into an email, replacing the src/href of the document with the CID returned by $message->attach() and see what happens :)

Posted: Mon Jul 16, 2007 10:40 am
by roscoe
silly question but what is the CID and what does it do?

They are settling for HTML with images (would they be attachments in the case of embedded pics?)

Posted: Tue Jul 17, 2007 2:27 am
by Chris Corbyn
roscoe wrote:silly question but what is the CID and what does it do?

They are settling for HTML with images (would they be attachments in the case of embedded pics?)
The CID is the ID of the particular area of content you want to reference (Content-ID). Like with HTML you'll be used to doing:

Code: Select all

<img src="http://some.server/images/image.png" />
With embedded images you do:

Code: Select all

<img src="cid:the-content-id-of-some-image" />
Swift generates that Content-ID string when you attach the image. How you use it is up to you ;)

Posted: Tue Jul 17, 2007 3:13 am
by roscoe
Sorry, further silly question, So you upload the HTML, upload the pics as attachments (Does it know where each pic belongs ?) (how do you get the CID from Swift to add it to the HTML?)

This bit is kind of new to me.

Posted: Tue Jul 17, 2007 7:16 am
by Chris Corbyn
The image needs to be a local image on the server's filesystem. See this:

http://www.swiftmailer.org/wikidocs/v3/ ... ing_images

Posted: Tue Jul 17, 2007 7:50 am
by roscoe
So to confirm, I create the HTML and where the images (I need more than one) should live I put in

Code: Select all

<php? <img src=\" . $message->attach(new Swift_Message_Image(new Swift_File("/path/to/image.jpg"))) . "\  >, \"text/html\")); ?>
(the path of the file I know from where it uploads attachments directly to the server)

cos this bit should be inside the HTML?
Or could I upload the HTML with the paths already set ?

Code: Select all

<img src="mypath/myplace/myserver/mypic.jpg">


Can you write <php? ?> with HTML extension???

Sorry I am being so dense, perhaps it is the thunder.

Posted: Tue Jul 17, 2007 9:22 am
by Chris Corbyn
roscoe wrote:So to confirm, I create the HTML and where the images (I need more than one) should live I put in

Code: Select all

<php? <img src=" . $message->attach(new Swift_Message_Image(new Swift_File("/path/to/image.jpg"))) . "\  >, "text/html")); ?>
(the path of the file I know from where it uploads attachments directly to the server)

cos this bit should be inside the HTML?
Or could I upload the HTML with the paths already set ?

Code: Select all

<img src="mypath/myplace/myserver/mypic.jpg">


Can you write <php? ?> with HTML extension???

Sorry I am being so dense, perhaps it is the thunder.

Code: Select all

$cid = $message->attach(new Swift_Message_Image(new Swift_File("/some/image.png")));

$body = "Here's an image <img src="" . $cid . "" /> and the same again <img src="" . $cid . "" />";

$message->attach(new Swift_Message_Part($body, "text/html"));

Posted: Wed Jul 18, 2007 3:01 am
by roscoe
I am assuming that as $cid would only cover one image, I would need to add variables :

Code: Select all

$cid = $message->attach(new Swift_Message_Image(new Swift_File("/some/image.png"))); 

$cid2 = $message->attach(new Swift_Message_Image(new Swift_File("/some/image2.png")));
etc.

Thanks :)