PHP Image in Email
- Started
- Last post
- 7 Responses
- ethanfink
Anyone know what I am doing wrong in this PHP script. I am basically trying to have a img embedded in an email via post. Any thoughts on my crappy coding?
$Subject2 = "Subject title $toName";
$Message2 = "<img src='http://weburl.com/subdir/assets/imagename.jpg' />\nDear $fromName,\n\nSentence ...\n\nSentence ... \n\Sentence ...link:\nhttp://www.google.com... \nJohn\n";
- vaxorcist0
you have to have a proper header....
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"also see:
http://css-tricks.com/sending-ni…
http://code.web-max.ca/misc_html…- I'd go to one of the links and cut-paste their code, get it to work, then tweek it..vaxorcist
- ethanfink0
So nice vaxorcist... now how do I add PHP variables to a HTML formated header...?
It works, but then it renders my php inside the mail to html text, no the variable output :(
- vaxorcist0
oh....
use $var = statements, not <?php
like:
$message_body = "hello $user, your order is $price";
then use the $message_body variables and others in the php mail function
- acescence0
if your vars are showing up as $var in the body instead of their value, you've probably got a single vs double quote issue.
- ethanfink0
Finally got it... you guys are the best :)
This is what my working message variable looks like using html and php variables.
$Message2 = "<img src='http://imageurl.com/assets/logo.jpg' />\nDear " . $_POST['fromName'] . " ,\n\nYou have received this email as confirmation.";
- vaxorcist0
you can also use heredocs string syntax to avoid quotes and dots....
$message = <<<EOD
whatever $the_var is'nt it is <img src="http://www.me.com/hello.gif">
EOD;
- designmachine0
looks correct to me @ethanfink