Jump to content

html in php send email disappears?


wmguk

Recommended Posts

Hi guys,

 

I'm just running some test emails, and I cant quite work this out.

 

Basically if the email is displayed in hotmail.com then everything except the page background shows, however if its displayed in Outlook 2007 then only the background is displayed... basically all images and formatting disappears.

 

Can anyone see what I could do differently?

 


$mime_boundary = "IW Photo".md5(time());

# -=-=-=- MAIL HEADERS

$to = "$email";
$subject = "Your have a guestbook message";

$headers = "From: Imagine Wedding Photography <[email protected]>\n";
$headers .= "Reply-To: Imagine Wedding Photography <[email protected]>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

# -=-=-=- HTML EMAIL PART

$message = "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= "<html>\n";
$message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:8px; background-color: #666666;\">\n"; 
$message .= "<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='80' align='left' valign='top' background='http://domain.co.uk/images/frameset/top.jpg'><p> </p></td></tr><tr><td align='left' valign='top' background='http://domain.co.uk/images/frameset/middle.jpg'>";
$message .= "<table width='800' border='0' cellspacing='0' cellpadding='0'><tr><td width='20'> </td>";
$message .= "<td class='main'>$title,";
$message .= "<p>Your guestbook has been written in.</p>";
$message .= "<p>You need to view and authorise this message so other people can view the message.</p>";
$message .= "<p>Please click <a href='https://www.domain.co.uk/'>HERE</a> to log in. </p>";
$message .= "<p>Your account details are Album Name: <strong><em>$login</em></strong> and Email Address: <em><strong>$email</strong></em>.</p>";
$message .= "<p>Once you have logged in, simply click on guestbook and you can read and authorise the message. You will get this email every time someone leaves a message for you, However this isnt instant and can take anytime from minutes to hours, because of our SPAM checking proceedures.</p>";
$message .= "<p>Hope everything is well.</p>";
$message .= "<p>Regards.<br>";
$message .= "Imagine Wedding Photography.</p>";
$message .="</td><td width='20'> </td></tr></table></td></tr>";
$message .= "<tr><td align='left' valign='top' background='http://www.domain.co.uk/images/frameset/bottom.jpg'> </td></tr></table>";
$message .= "</body>\n";
$message .= "</html>\n";

# -=-=-=- FINAL BOUNDARY

$message .= "--$mime_boundary--\n\n";

# -=-=-=- SEND MAIL

$mail_sent = @mail( $to, $subject, $message, $headers );
}

Link to comment
https://forums.phpfreaks.com/topic/107183-html-in-php-send-email-disappears/
Share on other sites

hey,

 

I'm using that script above, however all i keep getting is :

 

Warning: file_get_contents(top.gif) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpsdocs/scripts/htmlMimeMail5.php on line 929

 

Warning: file_get_contents(middle.gif) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpsdocs/scripts/htmlMimeMail5.php on line 929

 

Warning: file_get_contents(bottom.gif) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpsdocs/scripts/htmlMimeMail5.php on line 929

 

line 929 is:

parent::__construct(file_get_contents($filename), basename($filename), $contentType, $encoding);

 

on line 375 it allows you to set the dir, and the only thing is the images are www.domain.co.uk/images/frameset/

 

I have set:

    function setHTML($html, $images_dir = '/var/www/vhosts/domain.co.uk/httpsdocs/images/frameset/')
    {
        $this->html = $html;

        if (!empty($images_dir)) {
            $this->findHtmlImages($images_dir);
        }
    }

 

i also used " and nothing at all, and then set to https://www.domain.co.uk/images/framset and its just not working :(

 

has anyone used this script to do this? can anyone point me in the right directions please?

hey,

 

ok, ive checked out the examples and how stupid, i was setting my images as gif, but they were jpg :(

 

however I've noticed it doesnt allow real html, as in, tables etc.

 

the images that are table backgrounds dont show up and the widths etc dont show up.

 

this is the html code

    $mail->setHTML('<body style="font-family:Verdana, Verdana, Geneva, sans-serif; font-size:8px; background-color: #666666;">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="80" align="left" valign="top" background="top.jpg"><p> </p></td></tr><tr><td align="left" valign="top" background="middle.jpg">
<table width="800" border="0" cellspacing="0" cellpadding="0"><tr><td width="20"> </td>
<td class="main">$title,
<p>Your guestbook has been written in.</p>
<p>You need to view and authorise this message so other people can view the message.</p>
<p>Please click <a href="https://www.domain.co.uk/">HERE</a> to log in.</p>
<p>Your account details are Album Name: <strong><em>$login</em></strong> and Email Address: <em><strong>$email</strong></em>.</p>
<p>Once you have logged in, simply click on guestbook and you can read and authorise the message. You will get this email every time someone leaves a message for you, However this isnt instant and can take anytime from minutes to hours, because of our SPAM checking proceedures.</p>
<p>Hope everything is well.</p>
<p>Regards.</p>
</td><td width="20> </td></tr></table></td></tr>
<tr><td align="left" valign="top" background="bottom.jpg"> </td></tr></table>
</body>');

 

also i dont seem to be able to pass $var...

 

this is my from code

    $mail->setFrom('Imagine Wedding Photography <$email>');

 

however when i get my email, it says $email, rather than the value of $email...

 

any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.