Easy email question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Easy email question

Post 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.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

well, if you post your code then i am sure someone will help you out :).
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post 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);
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post 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);
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post 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...
Post Reply