gotornot Posted September 28, 2009 Share Posted September 28, 2009 H Peeps Im looking at sending both html and text email at the same time. Im not sure how to do this i can send them both independantly but am not sure on the dual method. Any ideas? Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/ Share on other sites More sharing options...
ILMV Posted September 28, 2009 Share Posted September 28, 2009 Have you considered asking the user whether they want to receive text or HTML emails, then just do an if statement, one sending HTML, one sending plain text. Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926326 Share on other sites More sharing options...
gotornot Posted September 28, 2009 Author Share Posted September 28, 2009 yes but... That wasnt the answer I was looking for. im looking in more general terms. Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926327 Share on other sites More sharing options...
Mark Baker Posted September 28, 2009 Share Posted September 28, 2009 There's an example somebody has given here in the PHP Manual Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926328 Share on other sites More sharing options...
CarbonCopy Posted September 28, 2009 Share Posted September 28, 2009 http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php <?php //define the receiver of the email $to = '[email protected]'; //define the subject of the email $subject = 'Test 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\n $headers = "From: [email protected]\r\nReply-To: [email protected]"; //add boundary string and mime type specification $headers .= "\r\nContent-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"; ?> This shows the text part if HTML is disabled, not sure if this is what you want. Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926331 Share on other sites More sharing options...
gotornot Posted September 28, 2009 Author Share Posted September 28, 2009 excellent replies but i am confussed by the coding hopefully it will be simple enough from the examples dont kow why you would need to use the rand funcs tho dont understand that bit Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926335 Share on other sites More sharing options...
Mark Baker Posted September 28, 2009 Share Posted September 28, 2009 excellent replies but i am confussed by the coding hopefully it will be simple enough from the examples dont kow why you would need to use the rand funcs tho dont understand that bitEach "part" (text and html) needs a unique boundary marker. The random functions ensure that the boundary markers are unique. Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926338 Share on other sites More sharing options...
gotornot Posted September 28, 2009 Author Share Posted September 28, 2009 hi Mark Its not working its just throwing it all out together. Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926393 Share on other sites More sharing options...
gotornot Posted September 28, 2009 Author Share Posted September 28, 2009 i got it working thanks guys your all stars... when i have taken over richard branston i will remember you. Link to comment https://forums.phpfreaks.com/topic/175790-solved-how-do-i-send-text-and-html-email-at-the-same-time/#findComment-926403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.