EVM_Mailer PHP Email Object Class Doc File


USAGE:

set_sender( string:sender name , string:sender email )
This sets the "From:" field in the email message. The email string is limited to 255 characters.

set_subject( string:subject )
This sets the "Subject:" field in the email message. The string is limited to 255 characters.

set_message_type( "text" || "html" )
Sets the mime-type of the body of the email.

set_message( string:email body )
This sets the body of the email message.

add_recipient( string:recipient name , string:recipient email )
This can be used to add multiple recipients to the "To:" field of the email message. The email string is limited to 255 characters.

add_CC( string:carbon copy name , string:carbon copy email )
This can be used to add multiple recipients to the "CC:" field of the email message. The email string is limited to 255 characters.

add_BCC( string:blind carbon copy name , string:blind carbon copy email )
This can be used to add multiple recipients to the "BCC:" field of the email message. The email string is limited to 255 characters.

add_attachment( string:name of file , string:location of file , string:mime-type )
This can be used to add multiple attachments to the email message. Currently, there is no error checking for extreme file sizes.

get_actions()
Returns a string of successful actions performed in the script.

get_warnings()
Returns a string of potential errors in the script.

get_errors()
Returns a string of all critical errors in the script.

send()
Sends the email message using the PHP mail() function as its base.


USAGE EXAMPLE: (sets email information, adds attachments from a web form, sends the email and then displays all events during the processing of this script.)

$simple_mailer = new EVM_Mailer(); // create new EVM_Mailer object
$simple_mailer->set_sender("Sender Name","sender@domain.com"); // set sender name and email address
$simple_mailer->set_subject("The Easiest PHP emailing script on the web"); // set the subject line of the email
$simple_mailer->set_message_type("html"); // text or html mime-type
$simple_mailer->set_message("Build your email body message and place here."); // set the message body of the email message
$simple_mailer->add_recipient("Somebody Important","somebody@domain.com"); // add a recipient to the email To: list
$simple_mailer->add_recipient("SombodyElse Important","somebodyelse@domain.com"); // add a recipient to the email To: list
$simple_mailer->add_CC("Sombody LessImportant","lessimportant@domain.com"); // add a recipient to the email CC: list
$simple_mailer->add_BCC("My Boss","myboss@domain.com"); // add a recipient to the email BCC: list
$simple_mailer->add_BCC("Your Boss","yourboss@domain.com"); // add a recipient to the email BCC: list
while (list($key, $val) = each($_FILES)) { // reads uploaded files from a web form
     if ($_FILES[$key]['size'] > 0) { // if the filesize is > 0
          if ($_FILES[$key]['error'] == 0) { // and if there were no errors
               $simple_mailer->add_attachment($_FILES[$key]['name'],$_FILES[$key]['tmp_name'],$_FILES[$key]['type']); // add the file as an attachment
          }
     }
}
$simple_mailer->send(); // send the email
echo $simple_mailer->get_actions(); // display all actions performed during the processing
echo $simple_mailer->get_warnings(); // display all warnins during the processing
echo $simple_mailer->get_errors(); // display all errors during the processing


USAGE EXAMPLE 2: (minimal)

$simple_mailer = new EVM_Mailer(); // create new EVM_Mailer object
$simple_mailer->set_sender("Sender Name","sender@domain.com"); // set sender name and email address
$simple_mailer->set_subject("The Easiest PHP emailing script on the web"); // set the subject line of the email
$simple_mailer->set_message("Build your email body message and place here."); // set the message body of the email message
$simple_mailer->add_recipient("Somebody Important","somebody@domain.com"); // add a recipient to the email To: list
$simple_mailer->send(); // send the email


NOTES:

You may need to add scope to this object depending on which version of PHP you have installed on your server. For more information, check out the PHP.net website for variable and function scope.

Also, I have put alot of effort into creating and debugging this script and optimizing the neccesary functions to provide a robust, yet easy to use solution for any emailing project. If you use this script in your applications, I just ask to retain the current object and filename of EVM_Mailer.


ABOUT THE AUTHOR:

Eric Maksim ( ericvmaksim@hotmail.com ) is a web designer/developer who has been working in the internet industry for over 7 years, with programming experience of almost 20 years (I'm sure that C64 coding still counts for something). Recently been working mainly with LAMP (Linux, Apache, MySQL, PHP) projects as a contractor and also as an Internet Media business owner.