Page 1 of 1

php mail not sending image

Posted: Thu Mar 06, 2008 1:20 pm
by kryles
Hi,

I am sending an HTML formatted email, and everything is sent except the image. I'm pretty sure the path is right

public html -> folder1 -> webFolder -> include.php
-> index.php
-> images -> logo.gif

I am using index.php which includes webFolder/includes.php

this is the code I am using

Code: Select all

 
 
$to = $email;
$subject = "Your Password";
$from = "info@company.com";
$msg .= "<html><head><title></title></head><body>";
$msg .= '<img src="/images/logo.gif"><p></p>';
$msg .= "Dear Valued customer,<p>";
$msg .= "You have recently requested your password. <br \>";
$msg .= "Requested Password: ". $row[0] ."<br \>";
$msg .= "<a href='".STOREURL."/login.php'>".STOREURL."/login.php</a><br \>";
$msg .= "Please click the link above, or if it is not displaying then copy paste it into your browser</p><br \>";
$msg .= "Regards, <br \>";
$msg .= "</body></html>";
$header = "MIME-Version: 1.0" . "\r\n";
$header .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$header .= "From: info@company.com";
 
if(!mail($to, $subject, $msg, $header))
{
    echo '  An error has occured sending your email
        <p>Go <a href="'.STOREURL.'"/forgotten-password.php">BACK and try again
        Or <a href="'.STOREURL.'/contactmail.php">Contact us</a></p>';
}
else
{
    echo "mail succesfully sent to $to";
    echo "<p><a href='".STOREURL."/login.php'>Back to login</a>";
}
 
I played with the path because I thought that could be the issue. I tried "/images/logo.gif" "images/logo.gif" and "../images/logo.gif"

Re: php mail not sending image

Posted: Thu Mar 06, 2008 1:32 pm
by Christopher
For HTML email, you either need to specify a full URL with domain name for the URL or add the image as an attachment and address it by its attachment name.

Re: php mail not sending image

Posted: Thu Mar 06, 2008 1:35 pm
by kryles
that did the trick :)

thanks so much!