embedded images
Moderators: Chris Corbyn, General Moderators
embedded images
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.
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.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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?
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?
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:
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.
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);
...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".
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".
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Embedded Images are not the same as attachments. Outlook sends attachments so you're comparing apples to pearsfrenzal 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".
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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 
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.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?
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?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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.
Can't help feeling like the typical noob in this thread, firing of questions every 5 seconds
Just for the record, swift messages sent to an outlook email display fine.