Source for file xPliciMail.class.php
Documentation is available at xPliciMail.class.php
*@=@=@=@ START LICENSE @=@=@=@*
Copyright or © or Copr. Stéphane TRICHET and Nicolas SOTRON
stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
This software is a computer program whose purpose is to make a
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
*@=@=@=@ END LICENSE @=@=@=@*
* @version $Id: xPliciMail.class.php 913 2008-03-19 15:46:33Z stephanet $
require_once('Mail.php');
require_once('Mail/mime.php');
* Abstract class to send an email
* @version $Id: xPliciMail.class.php 913 2008-03-19 15:46:33Z stephanet $
* Interface needed for sending mail
* recipients separated by coma
* List of body type authorised : HTML,PLAIN_TEXT
* Constructor, init the requests and objects
* @param bool $send_from_admin_super
function xPliciMail($send_from_admin_super =
false) {
$object_internalmail =
& $g_object_loader->getTInternalMail();
$params_for_interface =
unserialize($object_internalmail->getValueOf("PARAMETERS", serialize(array())));
// informations locales à chaque site Internet
if ($send_from_admin_super ==
false) {
// on charge les paramètres pour l'envoi en interne à partir de la
// base de donnée du super admin
$array_mail_settings =
array();
$object_tglobalscope =
& $g_object_loader->getTGlobalScopeVariable();
$object_tglobalscope->getMailSettings($array_mail_settings, false);
// Set body type authorized
// Create the mail object using the Mail::factory method
* @param string $p_string
* Set recipients separated by coma
* @param string $p_recipients
* @param string $p_body_type
// Verify if is valid type
* @param string $p_content
* @return bool TRUE on error
function xSend($p_content) {
// On construit proprement le from et le from_name
'Content-Type' =>
'text/html'
if (isset
($array_recipients) && isset
($array_recipients[0]))
$headers['To'] =
$array_recipients[0];
// on crée un mail au format texte BRUT et texte HTML
$object_dbconnexion =
& $g_object_loader->getDbConnexion();
$object_Mail_mime =
new Mail_mime("WINNT"==
PHP_OS?
"\r":
"".
"\n"); $text_html =
$p_content;
$text_brut =
$object_dbconnexion->translate("HTML_TO_PLAIN", $text_html);
$object_Mail_mime->setTXTBody($text_brut, false, false);
// If necessary use email HTML headers
$object_Mail_mime->setHTMLBody($text_html, false, true);
$p_content =
$object_Mail_mime->get();
// on ajoute les headers pour le mime_type
$headers =
array_merge($headers, $object_Mail_mime->headers());
$headers['Subject'] =
$object_dbconnexion->translate("HTML_TO_PLAIN_STRING",
// add an empty because it help when using the Mail interface
$value_to_return =
$this->mail_object->send($array_recipients, $headers, $p_content);
$there_is_an_error =
false;
if (PEAR::isError($value_to_return)) {
trigger_error("[".
date("D M d G:i:s Y").
"] ".
"xPliciMail.class.php error: ".
$value_to_return->getMessage().
"\n");
if ($this->m_debug) echo_net("[".
date("D M d G:i:s Y").
"] ".
"xPliciMail.class.php error: ".
$value_to_return->getMessage().
"\n");
$there_is_an_error =
true;
return $there_is_an_error;
* Convert cotent with base mail template
* @param string $p_content
// on ajoute les headers et footer obligé au mail
// en utilisant un template
$smarty_for_mail =
& $g_object_loader->getSmarty_custom();
$cache_backup_status =
$smarty_for_mail->canNotBeCached();
$smarty_for_mail->setCannotBeCached(true);
$smarty_for_mail->assign_by_ref('mail_content', $p_content);
// il faut aller chercher le template dans le front
$object_siteinformation =
& $g_object_loader->getSiteInformation();
$file_mail_sent_name =
'mail_base.html';
//if ($object_siteinformation->isAdmin())
$object_siteinformation->getExistTemplateNotCompiledFilePath($file_mail_sent_name, $prefix_for_front, true);
$p_content =
$smarty_for_mail->fetch($prefix_for_front.
'mail_base.html');
$smarty_for_mail->setCannotBeCached($cache_backup_status);
// on code les adresses pour qu'elles soient absolues
$object_siteinformation =
& $g_object_loader->getSiteInformation();
$httpservername =
$object_siteinformation->getHttpServername(true);
$p_content =
ereg_replace ("(href|src)=([\"'])/", "\\1=\\2".
$httpservername.
"/", $p_content);
Documentation generated on Tue, 25 Mar 2008 15:37:32 +0100 by phpDocumentor 1.3.2