Page 1 of 1
embedded images
Posted: Thu Apr 12, 2007 9:00 am
by frenzal
Hi, i'm setting up a custom newsletter script using swiftmailer. How ever I seem to have run in to some problems embedding images.
If I were to make an e-mail in Outlook and insert a picture in my mail and send it to gmail that works fine and the picture displays in the email without any further clicks.
If i create an email with swift and embed images, these will show up as attachments and I'll have to click on "display images below". It's mentioned that this can happen in the docs, but that would mean gmail doesnt support embedded images but it does otherwise my outlook test wouldnt have worked in gmail.
Any ideas what's wrong with swift image embedding and has anyone got it working? Also how much of a performance killer is embedding, I notice that all newsletters I receive have external images and nothing embedded.
Posted: Thu Apr 12, 2007 9:32 am
by Chris Corbyn
Attach them, don't embed them. Outlook doesn't send embedded images, it just sends the attachment and the client chooses to display it inline. If you use Swift_Message_Attachment you should get the results you want.
PS: It works ok for me (and at least one other user who posted on this forum) with Gmail though. Can you post some code?
Posted: Thu Apr 12, 2007 9:38 am
by frenzal
Well i embed it the swift way, which does seem to use attach.
First i scan my message for all images (regex), and then replace them with an attached image. the gist of the loop is then this bit:
Code: Select all
...
$imgsrc = $home_dir . $img;
$embed =& new Swift_Message_Image(new Swift_File($imgsrc));
$src = $message->attach($embed);
//replace image with embedded image
$html = str_replace($img, $src, $html);
...
Anyway, I've just tested the swift test for embedded images and that shows up fine in gmail, so i must be missing something small.
Posted: Thu Apr 12, 2007 9:57 am
by frenzal
Bit of un update, the from address in the swift test was different then the one in my test email newsletter. In the passed I must of added this address to my approved emails i think which is why the picture shows up right away without needing to click display images.
Anyway, this still doesnt explain why an email sent with image in it from outlook (from various addresses) willdisplay the image in gmail, and if its from swift i have to click "display images".
Posted: Thu Apr 12, 2007 12:27 pm
by Chris Corbyn
frenzal wrote:Anyway, this still doesnt explain why an email sent with image in it from outlook (from various addresses) willdisplay the image in gmail, and if its from swift i have to click "display images".
Embedded Images are not the same as attachments. Outlook sends attachments so you're comparing apples to pears

If you just sent the image as an attachment you'd get the same results as with outlook. Embedded images are not "the Swift way"

Posted: Fri Apr 13, 2007 2:21 am
by frenzal
Hmm, can you show me how to display an attached image inline then that works in gmail?
Embedding an image with swift is no problem, attaching a file is fine too. But attaching a file to display inline without using the embed function? Now i'm confused

Posted: Fri Apr 13, 2007 2:23 am
by RobertGonzalez
Are you making sure to follow the instructions to the letter? I send out HTML mails all the time with embedded images and the images render in Outlook, GMail, Hotmail and Yahoo mail (as well as Thunderbird). I get an attachment, but the image is right in the (HTML) message.
Posted: Fri Apr 13, 2007 3:02 am
by frenzal
It all works, but i though it's possible to see the images right away without clicking display images first so they don't show up as attachments under the message at first.
Posted: Fri Apr 13, 2007 4:58 am
by Chris Corbyn
This is a common spam trick. Gmail is doing what a lot of mail clients do and hiding the images. I still haven't heard if you have tried sending the image as a plain attachment like you're doing with Outlook. Outlook does not send embedded images (not the same thing as an attachment). Outlook just chooses to display the image in the content editor that's all. I bet you cannot send your email with outlook and have the image appear in the middle of a block of text in Gmail? Try Swift_Message_Attachment... it's the last time I'll repeat myself

Posted: Fri Apr 13, 2007 6:15 am
by frenzal
d11wtq wrote:I bet you cannot send your email with outlook and have the image appear in the middle of a block of text in Gmail?
Well that's just what's confusing me, I can send an email with outlook that has a picture inserted in it. I even sent a test to a never used test gmail account and the image displayed without needing extra actions from me.
Anyway as for using the Swift_Message_Attachment, I said I tried it, and I can send a message. And it arrives with an attachment as expected. But i've found no information on how to display this image in my htl newsletter so I don't quite get how this helps me?
Posted: Fri Apr 13, 2007 6:24 am
by Chris Corbyn
I have to ask. What is the size of the image? I think Gmail makes you have a click a button to display images above a certain size.
Posted: Fri Apr 13, 2007 6:34 am
by frenzal
382px x 127px. Now in this case I was sending different images from outlook then with my swift mail. So i just sent the exact same image in a message with outlook and it appears in gmail right away.
Can't help feeling like the typical noob in this thread, firing of questions every 5 seconds

But i'm just trying to find cosistency in the way images are or are not displayed in gmail.
Just for the record, swift messages sent to an outlook email display fine.