PHP Classes

PHP HTML Formatted Mail : Send HTML email messages composed using templates

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (20)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 562 All time: 5,416 This week: 129Up
Version License PHP version Categories
send-formatted-mail 1.0.0GNU General Publi...4HTML, Email, Templates
Description 

Author

This class can send HTML email messages composed using templates.

It can compose message bodies from templates that are processed with PHPlib template processor.

The compose HTML messages can be sent by the MIME mail message. Messages may include embedded images.

Recommendations

Send emails fast
I need to send many emails

Picture of José Filipe Lopes Santos
  Performance   Level  
Name: José Filipe Lopes Santos <contact>
Classes: 4 packages by
Country: Portugal Portugal
Age: 52
All time rank: 182925 in Portugal Portugal
Week rank: 198 Up2 in Portugal Portugal Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php

/* form with
 * name
 * email
 * subject
 * message
 *
 * send to mail ....
 */


/**
 * Send ticket by email.
 *
 * @author José Filipe Lopes Santos <jfilipe@med.up.pt>
 * @since 09-05-2012
 * @version 1.0 - data da últ. actualização: 10-05-2012
 */

require_once 'conf/core.inc';
require_once
'lib/sendmail.inc';

/* ---------------------------------- oOo --------------------------------
                             Inicialização de variáveis
   ---------------------------------- oOo -------------------------------- */

if (empty($name)) $name = "";
if (empty(
$email)) $email = "";
if (empty(
$subject)) $subject = "";
if (empty(
$message)) $message = "";
if (empty(
$note_empty)) $note_empty = false; // booleano que indica se existem campos obrigatórios por preencher
if (empty($error_msg)) $error_msg = ""; // mensagem de erro
if (empty($sended)) $sended = "no"; // indica se já foi enviado ou não o ticket por email
if (empty($title)) $title = "Send a ticket";


/* ---------------------------------- oOo --------------------------------
             Verificar se existem campos obrigatórios por preencher
   ---------------------------------- oOo -------------------------------- */

if (!empty($submit) && ($name == "" || $email == ""))
   
$note_empty = true;
else
   
$note_empty = false;


/* ---------------------------------- oOo --------------------------------
                                  Enviar mails
   ---------------------------------- oOo -------------------------------- */

if (!empty($submit) && !$note_empty && $error_msg == ""){

   
// remetente / de e destinatário / para
   
$from = "Trouble Tickets (tts) <tts@med.up.pt>";
       
$to = "jfilipe@med.up.pt";

   
// criar uma nova instânca da classe para enviar mails
   
$sm = new sendmail(CRLF);

   
// adicionar template
   
$sm->addTemplate("page","mail_page.html");
       
$sm->addTemplate("info","info_ticket.html");
   
   
// mensagem de erro
   
if ($sm->error_msg != "") die("erro: ".$sm->error_msg."\n");

       
// adicionar imagem
       
$sm->addImage("images/cabecalho.gif","image/gif","cabecalho.gif");
               
   
// determinar os cabeçalhos
   
$subject_mail = "Ticket: ".$subject;
   
$headers = array("From" => $from, "Subject" => $subject_mail);

       
// Information to formatted message
        // can be get from database record
       
$info = array("name" => $name, "email" => $email, "subject" => $subject, "message" => $message);
               
   
// obter a mensagem formatada
       
$message = $sm->genFormattedMailMessage("ticket",$info,TEMPLATES_PATH,$subject_mail);

   
// mensagem de erro
   
if ($sm->error_msg != "") die("erro: ".$sm->error_msg."\n");

   
// enviar a mensagem
   
$sm->Send($message,$to,$headers);
   
   
// mensagem de erro
   
if ($sm->error_msg != "") die("erro: ".$sm->error_msg."\n");
       
       
$sended = "yes";
}

/* ---------------------------------- oOo --------------------------------
                     Output
   ---------------------------------- oOo -------------------------------- */


$t = new Template_PHPLIB(TEMPLATES_PATH);
             
$t->setFile(array("page" => "page.html",
                 
"form" => "form_ticket.html",
                 
"note" => "note_without_table.html",
         
"note2" => "note_without_table.html"));


//*********** Página (início) *************
$t->setVar(array("rooturl" => ROOT_URL, "titulo" => $title));


if (
ereg("yes",$sended)){ // enviado

    //*********** mensagem de sucesso *******
   
$t->setVar("msg","Ticket sended with sucess");
   
$t->parse("block_body","note",true);
   
} else {

   
//////// destacar os campos por preencher ///////////
   
if (!empty($submit) && $name == "") $t->setVar("symbol_name",SYMBOL_EMPTY);
    else
$t->setVar("symbol_name",SYMBOL_NORMAL);
    if (!empty(
$submit) && $email == "") $t->setVar("symbol_email",SYMBOL_EMPTY);
    else
$t->setVar("symbol_email",SYMBOL_NORMAL);

   
/////// setar variáveis //////
   
$t->setVar(array("name_value" => $name,
                    
"email_value" => $email,
                    
"subject_value" => $subject,
                    
"message_value" => $message));


   
//************* mensagem de erro ***********
   
if ($error_msg == "" && $note_empty) $error_msg = MSG_EMPTY;
    if (
$error_msg != ""){
           
$t->setVar(array("colspan_note" => 2, "msg" => $error_msg));
           
$t->parse("block_note","note2",true);
    }

   
//********** formulário (fim) **********
   
$t->parse("block_body","form",true);

}

//*********** Página (fim) *************
$t->pparse("output","page");

?>


Screenshots  
  • form
  • mail
  Files folder image Files  
File Role Description
Files folder imageSendFormattedMail (1 file, 6 directories)

  Files folder image Files  /  SendFormattedMail  
File Role Description
Files folder imageconf (1 file)
Files folder imagecss (2 files)
Files folder imageimages (7 files)
Files folder imagelib (1 file)
Files folder imagescreenshots (2 files)
Files folder imagetemplates (6 files)
  Accessible without login Plain text file ticket.php Example Form to send a formatted mail

  Files folder image Files  /  SendFormattedMail  /  conf  
File Role Description
  Accessible without login Plain text file core.inc Conf. Configurations

  Files folder image Files  /  SendFormattedMail  /  css  
File Role Description
  Accessible without login Plain text file common.css Data common styles
  Accessible without login Plain text file geral.css Data global application styples

  Files folder image Files  /  SendFormattedMail  /  images  
File Role Description
  Accessible without login Image file bg_body.gif Icon Icon image
  Accessible without login Image file bg_tit1.gif Icon Icon image
  Accessible without login Image file cabecalho.gif Icon Icon image
  Accessible without login Image file dot.gif Icon Icon image
  Accessible without login Image file dots.gif Icon Icon image
  Accessible without login Image file seta.gif Icon Icon image
  Accessible without login Image file ticket.gif Icon Icon image

  Files folder image Files  /  SendFormattedMail  /  lib  
File Role Description
  Plain text file sendmail.inc Class Class to send formattted mail

  Files folder image Files  /  SendFormattedMail  /  screenshots  
File Role Description
  Accessible without login Image file form.png Data form screenshot
  Accessible without login Image file mail.png Data mail received screenshot

  Files folder image Files  /  SendFormattedMail  /  templates  
File Role Description
  Accessible without login Plain text file form_ticket.html Data send ticket form
  Accessible without login Plain text file info_ticket.html Data ticket information
  Accessible without login Plain text file mail_page.html Data page to send mail
  Accessible without login Plain text file note_without_table.html Data Documentation
  Accessible without login Plain text file note_with_table.html Data Documentation
  Accessible without login Plain text file page.html Data page to display

 Version Control Unique User Downloads Download Rankings  
 0%
Total:562
This week:0
All time:5,416
This week:129Up