Send email

Anyone have php send mail code that is working which can send html and text version of email? So user who can see HTML email will be shown html, and user who can’t will be shown text message.

THanks.

Do you mean an email program for sending out emails? You can do this with Thunderbird, which is a free download. I think Outlook 03 does it too, but Outlook 07 doesn’t do it so well.

No, I’m looking for PHP code.

check out phpmailer. It’s a class that (among other things) assists you in sending html and text versions.

I’ve already check it, but It cant send two version of HTML and text email

There are plenty of tutorials online that might help, such as this:

http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

Are you wanting to send an html email with the plain text alternative?

If so the PHPMailer is perfectly capable of doing that.

Using HTML Email

Thanks. Exactly what I was looking for

This can be done through alternative boundary as per the code lines below.
<?php
//define the receiver of the email
$to = “toemail”;
//define the subject of the email
$subject = ‘HTML email’;
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date(‘r’,time()));
//define the headers we want passed. Note that they are separated with \r\

$headers = “From: fromemail\r
Reply-To: lovein@blaksmail.com”;
//add boundary string and mime type specification
$headers.= “\r
Content-Type: multipart/alternative;boundary=\“PHP-alt-”.$random_hash.”\“”;
//define the body of the message.
ob_start(); //Turn on output buffering
?>
–PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset=“iso-8859-1”
Content-Transfer-Encoding: 7bit

Hello World!!!
This is simple text email message.

–PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset=“iso-8859-1”
Content-Transfer-Encoding: 7bit

<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>

–PHP-alt-<?php echo $random_hash; ?>–
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print “Mail sent”. Otherwise print “Mail failed”
echo $mail_sent ? “Mail sent” : “Mail failed”;
?>

Original source for the above pasted code: http://www.eggheadcafe.com/community/aspnet/39/10099478/re.aspx