PHP Classes

File: nomad_mimemail.test.php

Recommend this page to a friend!
  Classes of Alejandro García González  >  Nomad MIME Mail  >  nomad_mimemail.test.php  >  Download  
File: nomad_mimemail.test.php
Role: Example script
Content type: text/plain
Description: Example
Class: Nomad MIME Mail
A class for sending MIME e-mail whit SMTP Support
Author: By
Last change: Test example file

This example, sends a Text + HTML + Embedded Image + Atachment eMail via Auth SMTP
Date: 9 years ago
Size: 2,311 bytes


Class file image Download
 * This example, sends a Text + HTML + Embedded Image + Atachment eMail
 * via Auth SMTP

 * We need to include the class and declare it
include ('');
$mimemail = new nomad_mimemail();

 * Asign SMTP values need to connect
 * Note: SMTP user can be a email if needs
$smtp_host = ""; // *Change Value*
$smtp_user = "user"; // *Change Value*
$smtp_pass = "pass"; // *Change Value*

 * Asign mail variables to create the mail
 * Check the $html var, have a img tag with src='image.gif'
$from = ""; // *Change Value*
$to = ""; // *Change Value*
$subject = "Nomad MIME Mail example";
$text = "This is a MIME Mail Plain Text\n\n";
$html = "<p>This is a <b>MIME</b> Mail with:</p>
           <li>Embedded Image</li>
           <img src='my_image.jpg' border='0'>"

 * Asign Atachments file path and name variables
$attach_image = "test_files/image.jpg";
$attach_file = "test_files/file.gz";

 * Asign all the vars in the class
// Shortcut to declare the 5 lines above
// $mimemail->new_mail($from, $to, $subject, $text, $html);

 * Adding Atachments with it's file name, you can see the
 * image name in the method is the same declared in the HTML text
 * for the Embedded Image works
$mimemail->add_attachment($attach_image, "my_image.jpg");
$mimemail->add_attachment($attach_file, "my_file.gz");

 * Asign the SMTP values to connect.
 * If you dont need Auth SMTP you can comment the set_smtp_auth method.
 * If you dont need any SMTP you can comment both lines and the mail sends via
 * PHP mail function.
//$mimemail->set_smtp_log(true); // If you need debug SMTP connection
$mimemail->set_smtp_auth($smtp_user, $smtp_pass);

 * Send the mail
if ($mimemail->send()){
"The MIME Mail has been sent";
else {
"An error has occurred, mail was not sent";

//echo "<br><br><textarea cols=80 rows=30>" . $mimemail->get_smtp_log() . "</textarea>"; // If you need debug SMTP connection


For more information send a message to info at phpclasses dot org.