PHP Classes

MIME E-mail message sending: PHP mailer to compose and send MIME messages

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-11-03 (1 month ago) RSS 2.0 feedStarStarStarStarStar 85%Total: 48,353 This week: 2All time: 5 This week: 31Down
Version License PHP version Categories
mimemessage 1.0.13BSD License3Email, Unix, Windows
Description 

Author

Class that may be used to compose and send e-mail messages.

It features:

- User definable headers and body parts.
- MIME encoding of text and HTML body parts with user defined character encoding using quoted-printable.
- Addition of file parts (attachments) with automatic content type detection.
- Forwarding of messages received from somebody else as intact attachments
- Support for multipart/related messages (eg. HTML messages with embedded images, stylesheets, frames, etc..)
- Support for multipart/alternative messages (eg. text and HTML versions in the same message).
- Encoding of message headers with user defined character encoding using q-encoding.
- Definition of the error delivery address setting the Return-Path header calling sendmail program directly.
- Several sub-classes for sending messages by different methods: PHP mail() function, sendmail, qmail, SMTP (with support for authentication and direct delivery mode), maildrop in Microsoft IIS or Exchange Pickup folder.
- Wrappers that emulate the mail() function using the SMTP, sendmail and qmail delivery sub-classes.
- Support for sending personalized bulk mail by replacing the contents of the message parts that differ for each recipient.
- HTML and plain text message parts can be composed using template engines. An example that works with Smarty template engine is provided.
- Retrieving the composed message data or size without sending the message

Picture of Manuel Lemos
  Performance   Level  
Name: Manuel Lemos is available for providing paid consulting. Contact Manuel Lemos .
Classes: 45 packages by
Country: Portugal Portugal
Age: 56
All time rank: 1
Week rank: 5 Down2 in Portugal Portugal Down

Recommendations

What is the best PHP p7m class to sign a PDF document?
Digitally signing a PDF document

password authentication email
I want email to send to users after authentication

Send emails fast
I need to send many emails

Find how to connect to SMTP server
Connect to SMTP mail server through IMAP

What is the best PHP send email with gmail class?
Send email SMTP gmail

Send many emails at once
Send a newsletter to many subscribers

Simple send file through email/contact page
Simple and complete methods to send files embedded

What is the best PHP html mail script class?
Send this mail every 15 days

Send email with attachment
Send an email attachment files

What is the best PHP mailer class?
PHP mailer that supports To, Cc and Reply-To

PHP Mailer class
Class for sending email

Import mailing list design
Import different formatted Excel list, personalize each mail

Example

<?php
/*
 * test_email_message.php
 *
 * @(#) $Header: /opt2/ena/metal/mimemessage/test_email_message.php,v 1.6 2003/10/05 17:32:56 mlemos Exp $
 *
 */

   
require("email_message.php");

   
$from_name=getenv("USERNAME");
   
$from_address=getenv("USER")."@".getenv("HOSTNAME");
   
$reply_name=$from_name;
   
$reply_address=$from_address;
   
$reply_address=$from_address;
   
$error_delivery_name=$from_name;
   
$error_delivery_address=$from_address;
   
$to_name="Manuel Lemos";
   
$to_address="mlemos@acm.org";
   
$subject="Testing Manuel Lemos' MIME Email composition PHP class: some non-ASCII characters ÁèÎõÜ in a message header";
   
$message="Hello ".strtok($to_name," ").",\n\nThis message is just to let you know that your e-mail sending class is working as expected.\n\nHere's some non-ASCII characters ÁèÎõÜ in the message body to let you see if they are sent properly encoded.\n\nThank you,\n$from_name";
   
$email_message=new email_message_class;
   
$email_message->SetEncodedEmailHeader("To",$to_address,$to_name);
   
$email_message->SetEncodedEmailHeader("From",$from_address,$from_name);
   
$email_message->SetEncodedEmailHeader("Reply-To",$reply_address,$reply_name);
/*
    Set the Return-Path header to define the envelope sender address to which bounced messages are delivered.
    If you are using Windows, you need to use the smtp_message_class to set the return-path address.
*/
   
if(defined("PHP_OS")
    &&
strcmp(substr(PHP_OS,0,3),"WIN"))
       
$email_message->SetHeader("Return-Path",$error_delivery_address);
   
$email_message->SetEncodedEmailHeader("Errors-To",$error_delivery_address,$error_delivery_name);
   
$email_message->SetEncodedHeader("Subject",$subject);
   
$email_message->AddQuotedPrintableTextPart($email_message->WrapText($message));
   
$error=$email_message->Send();
    if(
strcmp($error,""))
        echo
"Error: $error\n";
?>


  Files folder image Files (39)  
File Role Description
Files folder imagedocumentation (5 files)
Files folder imagetemplates (2 files)
Accessible without login Plain text file classmaps.php Aux. Class maps definition array
Plain text file email_message.php Class MIME E-mail composition and sending class
Accessible without login Plain text file get_gmail_oauth_access_token.php Example Script to retrieve the Gmail OAuth access token
Accessible without login Plain text file how_to_get_a_gmail_oauth_access_token.md Doc. Instructions on how to create a OAuth application to access the Gmail API
Accessible without login Plain text file message.eml Data Sample message file for demonstrating message forwarding support
Plain text file pickup_message.php Class Subclass to send composed messages using a Microsoft IIS or Exchange 2000 mail pickup folder
Accessible without login Plain text file qmail_mail.php Aux. Mail() emulation function using qmail_message_class
Plain text file qmail_message.php Class E-mail message sending sub-class of email_message_class using qmail
Accessible without login Plain text file sendmail_mail.php Aux. Mail() emulation function using sendmail_message_class
Plain text file sendmail_message.php Class Sendmail wrapper class to set Return-Path header and message queue options
Accessible without login Plain text file smtp_gmail.php Example Wrapper script that provides the gmail_smtp_mail function to replace the mail function and send messages via the Gmail SMTP server
Accessible without login Plain text file smtp_mail.php Aux. Mail() function emulation using smtp_message_class
Plain text file smtp_message.php Class Subclass to send composed messages using a SMTP server
Accessible without login Plain text file test_attachment_message.php Example Example script of how to send e-mail messages with attachment files.
Accessible without login Plain text file test_email_message.php Example MIME E-mail message class test script
Accessible without login Plain text file test_forwarding_message.php Example Test script for sending a MIME message that forwards another message
Accessible without login Plain text file test_html_mail_message.php Example Example script of how to send HTML e-mail messages.
Accessible without login Plain text file test_multibyte_message.php Example Example script of a page with a form to compose and send a message with multibyte characters text (Japanese, etc..)
Accessible without login Plain text file test_personalized_bulk_mail.php Example Test script for sending bulk mail with messages with contents personalized for each recipient.
Accessible without login Plain text file test_pickup_message.php Example Script to test the pickup_message class
Accessible without login Plain text file test_qmail_mail.php Example Test script for the Mail() function emulation using qmail_message_class
Accessible without login Plain text file test_quoted_printable.php Test Test suite for verifying the quoted printable encoding support.
Accessible without login Plain text file test_sendmail_mail.php Example Test script for the Mail() function emulation using sendmail_message_class
Accessible without login Plain text file test_simple_html_mail_message.php Example Example script to demonstrate how to send a simple HTML with the strongly recommended alternative text part
Accessible without login Plain text file test_smarty_personalized_mailing.php Example Test script for sending personalized bulk mailings using templates using the Smarty engine to compose HTML and plain text alternative parts of the messages.
Accessible without login Plain text file test_smtp_gmail.php Example Example script that provides the gmail_smtp_mail function to send messages via the Gmail SMTP server
Accessible without login Plain text file test_smtp_gmail_wi...auth_token_file.php Example Example script that provides the gmail_smtp_mail function to send messages via the Gmail SMTP server using a file to store OAuth token data
Accessible without login Plain text file test_smtp_mail.php Example Test script for the Mail() function emulation using smtp_message_class
Accessible without login Plain text file test_smtp_message.php Example Script to test the smtp_message class
Accessible without login Plain text file test_urgent_mail.php Example Test script for the urgent_mail() function
Accessible without login Plain text file urgent_mail.php Aux. mail() function replacement for urgent message delivery connecting directly to the recipient SMTP server and fallback to the mail function in case of temporary failure

  Files folder image Files (39)  /  documentation  
File Role Description
  Accessible without login HTML file email_message_class.html Doc. Documentation of the email_message_class
  Accessible without login HTML file pickup_message_class.html Doc. Documentation of the pickup_message_class
  Accessible without login HTML file qmail_message_class.html Doc. Documentation of the qmail_message_class
  Accessible without login HTML file sendmail_message_class.html Doc. Documentation of the sendmail_message_class
  Accessible without login HTML file smtp_message_class.html Doc. Documentation of the smtp_message_class

  Files folder image Files (39)  /  templates  
File Role Description
  Accessible without login Plain text file mailing.html.tpl Data Example HTML template for composing personalized mailings with the Smarty engine
  Accessible without login Plain text file mailing.txt.tpl Data Example plain text template for composing personalized mailings with the Smarty engine

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadmimemessage-2024-11-03.zip 121KB
Downloadmimemessage-2024-11-03.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
SMTP E-mail sending class Download .zip .tar.gz If it is used the SMTP message sub-class, this class is need to perform the actual SMTP delivery Conditional
Simple Authentication and Security Layer Download .zip .tar.gz This package is necessary when you need to send email messages via a SMTP server that requires authentication. Conditional
PHP OAuth Library Download .zip .tar.gz This package is necessary to obtain the OAuth token that is required by some SMTP servers that support the XOAUTH2 authentication mechanism. Conditional
 Version Control Reuses Unique User Downloads Download Rankings  
 84%2
Total:48,353
This week:2
All time:5
This week:31Down
User Ratings User Comments (19)
 All time
Utility:92%StarStarStarStarStar
Consistency:88%StarStarStarStarStar
Documentation:81%StarStarStarStarStar
Examples:84%StarStarStarStarStar
Tests:78%StarStarStarStar
Videos:63%StarStarStarStar
Overall:85%StarStarStarStarStar
Rank:3
 
ok
8 years ago (muabshir)
85%StarStarStarStarStar
The best class i've found that fits my needs to send bulk ema...
11 years ago (john marshall)
90%StarStarStarStarStar
good for practice
11 years ago (shyam6511)
100%StarStarStarStarStarStar
always worked for me
11 years ago (Helio)
90%StarStarStarStarStar
Yo! It's very usefull package.
11 years ago (Báris András)
97%StarStarStarStarStar
Doesn't work
13 years ago (LuisDiego)
7%Star
A very good package.
13 years ago (Wetter)
100%StarStarStarStarStarStar
It does what I needed.
14 years ago (marco zabel)
90%StarStarStarStarStar
good
14 years ago (rajeshkumar)
80%StarStarStarStarStar
One of my favourite packages! It works like a charm and it is...
14 years ago (Ingo Nehls)
95%StarStarStarStarStar
It's easy to use.
14 years ago (dewa)
85%StarStarStarStarStar
Excellent
15 years ago (kishore kumar)
100%StarStarStarStarStarStar
it changed my life! :-) very useful!
15 years ago (mannaro)
97%StarStarStarStarStar
All I have used so far in this impeccable class is email_mess...
16 years ago (Thales Jacobi)
87%StarStarStarStarStar
Needed changing to suit my individual needs, as expected.
16 years ago (Phil)
90%StarStarStarStarStar
My favorite PHP class when it comes to sending mail using a S...
16 years ago (Karthikeyan)
90%StarStarStarStarStar
Works perfectly
16 years ago (Daniel)
80%StarStarStarStarStar
The class makes the magic true.
16 years ago (Said Bakr)
77%StarStarStarStar
Pra evitar que seus emails não sejam entregues no Hotmail.
17 years ago (didi)
90%StarStarStarStarStar