Page 1 of 1

Easy email question

Posted: Tue Jul 22, 2003 4:36 am
by mikusan
I am not getting my email in HTML format, am i getting my headers wrong?
I don't have anything special, but should i have some kinda content type in the header? if so what is the code.

If i simply use my script to send an email, the email i receive is always plain text.

Posted: Tue Jul 22, 2003 5:08 am
by qads
well, if you post your code then i am sure someone will help you out :).

Posted: Tue Jul 22, 2003 5:16 am
by mikusan
It's the standard way of making a mailer:

Code: Select all

$headers = "From: <{$CFG['site_mail']}>\n";
	$headers .= "X-Sender: [" . $CFG['site_name'] . "]\n"; 

	//$headers .= "X-Priority: 1\n";	//Need checkbox

	$to = $_POST['email'];
	$subject = 'Newsletter Signup Confirmation';
 	$encryptmail = //secret hash

	$content .= 'This is a confirmation email that you have been added to ' . $CFG['site_name'] . '''s newsletter.

				 You will receive monthly updates and events.

				 To unsubscribe from this newsletter click the link: <a href="' . $CFG['site_url'] . 'signup.am?action=unsubscribe&code=' . $encryptmail . '>link</a>';

	//Send Email
	mail($to,$subject,$content,$headers);

Posted: Tue Jul 22, 2003 5:27 am
by qartis

Code: Select all

$headers = "From: <{$CFG['site_mail']}>\r\n";
$headers .= "X-Sender: [" . $CFG['site_name'] . "]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";

$to = $_POST['email'];
$subject = 'Newsletter Signup Confirmation';
$encryptmail = //secret hash

$content .= 'This is a confirmation email that you have been added to ' . $CFG['site_name'] . '''s newsletter.

             You will receive monthly updates and events.

             To unsubscribe from this newsletter click the link: <a href="' . $CFG['site_url'] . 'signup.am?action=unsubscribe&code=' . $encryptmail . '>link</a>';

mail($to,$subject,$content,$headers);

Posted: Tue Jul 22, 2003 5:30 am
by mikusan
Yes mime types...where was i with my head...
thanks...

Code: Select all

if (isset($vars['html'])) { 
 		$headers .= "Content-Type: text/html; charset=$charset\n"; // Mime type 
	}
	else {
        $headers .= "Content-Type: text/plain; charset=$charset\n";
If anyone needs it...