Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   sending email from php with html format (http://www.greenguysboard.com/board/showthread.php?t=60926)

pc 2011-02-25 03:55 PM

sending email from php with html format
 
$message gets content from textarea and it looks like this

Quote:

LINK text text text ANOTHER LINK IMG SRC more text
Code:


$mailTo = $_POST['emailTo'];
$mailFrom = $_POST['emailFrom\r\n'];
$subject = $_POST['subject'];
$message = $_POST['message'];

/* To send HTML mail, you can set the Content-type header. */
$headers  = "From: emailFrom\r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
           
mail($mailTo, $subject, $message, "From: ".$mailFrom, $headers);
?>

I'm scratching my head and can't figure it out, still have text emails.

pc 2011-02-25 09:38 PM

Well, I had it almost right, following solution works perfect :)

Code:


$mailTo = $_POST['emailTo'];
$mailFrom = $_POST['emailFrom\r\n'];
$subject = $_POST['subject'];
$message = $_POST['message'];

/* To send HTML mail, you can set the Content-type header. */
$headers  = "From: emailFrom\r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
           
mail($mailTo, $subject, $message, $headers, "From: ".$mailFrom);
?>

Sometimes I hear a ring, just don't know where exactly.


All times are GMT -4. The time now is 12:29 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc