Sending MAIL WITH IMAGES!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
D_zone
Forum Newbie
Posts: 14
Joined: Mon Nov 02, 2009 9:22 am

Sending MAIL WITH IMAGES!

Post by D_zone »

Does anybody know any tutorial or anything about sending images, not as an attachment but as background to a mail?
I have this code, It send the message but not the image, weird as it is, it worked and then didn't work. It seems pretty simple, but it's not. Hope anybody could help.

Code: Select all

 
<?php
 
    $to  = "your@email.com";
    $subject = "Test ";
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
    $from = "Your name<new@noreplay.com>";
    $headers .= "From: {$from}";
    
    $body = "
    <html>
    <head>
    <title>Test HTML Mail</title>
 
</head>
    <body >
    <font color='blue'>This is an html Mail</font>
    <table border='0' width = '461' height ='160' bgcolor='gray' align='center' background='http://www.domain.com/image.jpg'>
    <tr>
    <td><img src='http://www.domain.com/image2.jpg'></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    </table>
    </body>
    </html> 
";
 
 
mail($to, $subject, $body, $headers);
?> 
 
:?: :?: :?: :?:
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: Sending MAIL WITH IMAGES!

Post by akuji36 »

Since the image is NOT being sent I believe css can help you.

For example , I have php installed on my server so I can use the php

mail function to sent mail. Since the page is from my site I

can simply style the background using css--

See the css background image property here:


http://www.tizag.com/cssT/background.php

thanks

Rod :D
D_zone
Forum Newbie
Posts: 14
Joined: Mon Nov 02, 2009 9:22 am

Re: Sending MAIL WITH IMAGES!

Post by D_zone »

Thanks for replying akuji36,
I tried sending using css as well and didn't work either, like i said it worked only once where i finally saw the images in my mail box but it didn't last, it's weird.
I can color the background with no problem but the fact that I can't add images kills me.
Anybody has an idea why this happens?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Sending MAIL WITH IMAGES!

Post by Eric! »

It could be an issue with whatever program you're using for email. Why don't you create it in your email program and then view the raw mail file to see what it is doing.
D_zone
Forum Newbie
Posts: 14
Joined: Mon Nov 02, 2009 9:22 am

Re: Sending MAIL WITH IMAGES!

Post by D_zone »

I am not so sure what you're saying Eric, I am sending these mails to a GMAIL,YAYOO accounts I have but don't get images into none of them.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Sending MAIL WITH IMAGES!

Post by Eric! »

There isn't a standard that says 'this is how every email program will display background images.' So in gmail make your message with the image the way you want it and send it to your server. Then you can disect the raw html and can copy what gmail does.
Post Reply