How would i add an image at the top of a mail message body?
here is the current code i have:
<?
$recipient = "$emailto";
$subject = "subject text";
$message = "main text of message body";
$from = "$email";
$name=$_POST['name'];
$email =$_POST['email'];
$comments =$_POST['comments'];
$email2 =$_POST['emailto'];
mail($recipient,$subject,$message,"From address");
?>
(i MUST be able to see the image, not just as an attachment.
Thanks>> (I MUST be able to see the image, not just as an attachment.) <<
My email client saves all HTML code and all images as separate files. You cannot control that.
It leaves only the plain text in the message body. I like it that way.Well he could control it with emails that do allow them to see images in the email.PHPMailer cuts quite a bit of development time down with email and php. You might want to try the class, to imbed the image. There are tutorials on the site to get you going.
<!-- m --><a class="postlink" href="http://phpmailer.sourceforge.net/Where">http://phpmailer.sourceforge.net/Where</a><!-- m --> do i find the class.phpmailer.php ?Gotta Download it.
<!-- m --><a class="postlink" href="http://prDownload">http://prDownload</a><!-- m --> s.sourceforge.net/phpmailer/phpmailer-1.71.zip?Download what you have is invalid anyway. the last part where you have "From address" can't be like that.
<?
$recipient = $emailto;
$subject = "subject text";
$message = "<html><head><head><body>";
$message .= "<image src=http://www.htmlforums.com/archive/index.php/\"image.jpg\" border=\"0\"><br>";
$message .= "main text of message body";
$message .= "</body></html>";
$header = "From: address <[email protected]> \r\nContent-type: text/html\n";
mail($recipient,$subject,$message,$header);
?>
but again you can't make it visible if they do not except html email.Send ur self a message with an image enbeded, you can do it with the Outlook,editing the message as html
Then save the message, open as text and take a look at the headers, all u have to do is reproduce this header dinamically.
Here is a function to do so, just add the needed headers, all u have to do is add the image as an attachment and where u want the image to appear on the html, just put and id as a link, the way this is coded just look on the code generated by outlook or any other mailer.
<?php
function sendmessage($sender,$subject,$plain,$html,$targetEmail) {
//add From: header
$headers = "From: $sender\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//unique boundary
$boundary = uniqid("----=_NextPart_NLCPN_0000_");
//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative" .
"; boundary=\"$boundary\"\r\n\r\n";
//message to people with clients who don't
//understand MIME
$headers .= "This is a multi-part message in MIME format.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($plain)).
"\r\n";
//HTML version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($html)) .
"\r\n--$boundary--\r\n";
//send message
mail( $targetEmail, $subject, "", $headers);
}
?>rmortega77: I have already told you that your code is messed up, you do not need all that code to send html email. also that looks nothing like the headers in outlook. this post has nothing to do with outlook anyway.
here is the current code i have:
<?
$recipient = "$emailto";
$subject = "subject text";
$message = "main text of message body";
$from = "$email";
$name=$_POST['name'];
$email =$_POST['email'];
$comments =$_POST['comments'];
$email2 =$_POST['emailto'];
mail($recipient,$subject,$message,"From address");
?>
(i MUST be able to see the image, not just as an attachment.
Thanks>> (I MUST be able to see the image, not just as an attachment.) <<
My email client saves all HTML code and all images as separate files. You cannot control that.
It leaves only the plain text in the message body. I like it that way.Well he could control it with emails that do allow them to see images in the email.PHPMailer cuts quite a bit of development time down with email and php. You might want to try the class, to imbed the image. There are tutorials on the site to get you going.
<!-- m --><a class="postlink" href="http://phpmailer.sourceforge.net/Where">http://phpmailer.sourceforge.net/Where</a><!-- m --> do i find the class.phpmailer.php ?Gotta Download it.
<!-- m --><a class="postlink" href="http://prDownload">http://prDownload</a><!-- m --> s.sourceforge.net/phpmailer/phpmailer-1.71.zip?Download what you have is invalid anyway. the last part where you have "From address" can't be like that.
<?
$recipient = $emailto;
$subject = "subject text";
$message = "<html><head><head><body>";
$message .= "<image src=http://www.htmlforums.com/archive/index.php/\"image.jpg\" border=\"0\"><br>";
$message .= "main text of message body";
$message .= "</body></html>";
$header = "From: address <[email protected]> \r\nContent-type: text/html\n";
mail($recipient,$subject,$message,$header);
?>
but again you can't make it visible if they do not except html email.Send ur self a message with an image enbeded, you can do it with the Outlook,editing the message as html
Then save the message, open as text and take a look at the headers, all u have to do is reproduce this header dinamically.
Here is a function to do so, just add the needed headers, all u have to do is add the image as an attachment and where u want the image to appear on the html, just put and id as a link, the way this is coded just look on the code generated by outlook or any other mailer.
<?php
function sendmessage($sender,$subject,$plain,$html,$targetEmail) {
//add From: header
$headers = "From: $sender\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//unique boundary
$boundary = uniqid("----=_NextPart_NLCPN_0000_");
//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative" .
"; boundary=\"$boundary\"\r\n\r\n";
//message to people with clients who don't
//understand MIME
$headers .= "This is a multi-part message in MIME format.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($plain)).
"\r\n";
//HTML version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($html)) .
"\r\n--$boundary--\r\n";
//send message
mail( $targetEmail, $subject, "", $headers);
}
?>rmortega77: I have already told you that your code is messed up, you do not need all that code to send html email. also that looks nothing like the headers in outlook. this post has nothing to do with outlook anyway.