?
Solved

Best PHP class for email

Posted on 2009-02-11
1
Medium Priority
?
292 Views
Last Modified: 2012-05-06
I'm looking for a good PHP class to use for the emailing functions on my website. Any good suggestions of classes you have personally used?
0
Comment
Question by:DarkHill
1 Comment
 
LVL 2

Accepted Solution

by:
nativestudios earned 2000 total points
ID: 23611389
HI DarkHill,

Here's the one I use regularly (it allows for both plain text and HTML formatted emails):
function multipart_mail($to, $subject, $html_message, $text_message, $from_address, $from_display_name=''){
     $headers = $from_display_name == '' ? "From: ".$from_address : "From: ".$from_display_name." <".$from_address.">";
     $semi_rand = md5(time()); 
     $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
 
     $headers .= "\nMIME-Version: 1.0\n";
     $headers .= "Content-Type: multipart/alternative;\n";
     $headers .= " boundary=\"{$mime_boundary}\""; 
		
     $email_message =
     $email_message .= "This is a multi-part message in MIME format.\n\n"; 
     $email_message .= "--{$mime_boundary}\n";
     $email_message .= "Content-Type:text/plain; charset=\"iso-8859-1\"\n";
     $email_message .= "Content-Transfer-Encoding: 7bit\n\n"; 
     $email_message .= $text_message . "\n";
     $email_message .= "--{$mime_boundary}\n"; 
     $email_message .= "Content-Type:text/html; charset=\"iso-8859-1\"\n"; 
     $email_message .= "Content-Transfer-Encoding: 7bit\n\n";
     $email_message .= $html_message;
		
     return @mail($to, $subject, $email_message, $headers); 
		
}

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question