Skip to content
Snippets Groups Projects
Commit 3e45cf85 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: clean code

parent ce165a67
No related branches found
No related tags found
No related merge requests found
......@@ -226,115 +226,6 @@ class CMailFile
// comme des injections mail par les serveurs de messagerie.
$this->headers = preg_replace("/([\r\n]+)$/i","",$this->headers);
}
/*
else if ($conf->global->MAIN_MAIL_SENDMODE == 'simplemail')
{
// Use simplemail library
// ------------------------------------------
require_once(DOL_DOCUMENT_ROOT."/includes/simplemail/class.mail.php");
$mail = new simplemail();
$mail->set_mode='php'; // php or socket
// Boundaries
$mail->B1B = $this->mime_boundary;
$mail->B2B = $this->related_boundary;
$mail->B3B = $this->alternative_boundary;
$mail->XMailer = "Dolibarr version " . DOL_VERSION ." (using simplemail)";
// Add Errors-To
$mail->ErrorsTo = $this->getValidAddress($errors_to,1);
//Add Return-Path
$mail->returnpath = $this->getValidAddress($errors_to,1);
// Add from
$this->addr_from = $from;
$mail->hfrom=$this->getValidAddress($this->addr_from,0,1);
// Add delivery receipt
if ($deliveryreceipt)
{
$mail->deliveryreceipt=$this->getValidAddress($this->addr_from,0,1);
}
// Add to
$arrayTo=explode(',',$to);
foreach($arrayTo as $val)
{
$mail->recipientlist[] = array( 'mail'=>$this->getValidAddress($val,2), 'nameplusmail' => $this->getValidAddress($val,0,1));
}
// Add carbon copy
if (!empty($addr_cc))
{
$arrayTocc=explode(',',$addr_cc);
foreach($arrayTocc as $val)
{
if (!empty($mail->hcc)) $mail->hcc.= ",";
$mail->hcc.= $this->getValidAddress($val,0,1);
}
}
// Add carbon copy cache
if (!empty($addr_bcc))
{
$arrayTobcc=explode(',',$addr_bcc);
foreach($arrayTobcc as $val)
{
if (!empty($mail->hbcc)) $mail->hbcc.= ",";
$mail->hbcc.= $this->getValidAddress($val,0,1);
}
}
// Add subject
$mail->addsubject($this->encodetorfc2822($subject));
// Add message
if ($this->msgishtml)
{
if (! empty($this->html))
{
if (!empty($css))
{
$this->css = $css;
$this->styleCSS = $this->buildCSS();
}
$msg = $this->html;
$msg = $this->checkIfHTML($msg);
// un attachement html ( image jointe afficher ds le html ).
if ($this->atleastoneimage)
{
foreach ($this->html_images as $i => $val)
{
$mail->addhtmlattachement($this->html_images[$i]['fullpath'],$this->html_images[$i]['cid'],$this->html_images[$i]['content_type']);
}
}
}
// HTML format
$mail->html = $msg;
}
else
{
// Text format
$mail->text = $msg;
}
// Attach-files
if ($this->atleastonefile)
{
foreach ($filename_list as $i => $val)
{
$mail->addattachement($filename_list[$i]);
}
}
$this->simplemail = $mail;
}
*/
else if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
{
// Use SMTPS library
......@@ -478,56 +369,6 @@ class CMailFile
if (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)) ini_restore('SMTP');
if (! empty($conf->global->MAIN_MAIL_SMTP_PORT)) ini_restore('smtp_port');
}
/*
else if ($conf->global->MAIN_MAIL_SENDMODE == 'simplemail')
{
// Use simplemmail function (Simplemail method)
// --------------------------------------------
dol_syslog("CMailFile::sendfile addr_to=".$this->addr_to.", subject=".$this->subject, LOG_DEBUG);
dol_syslog("CMailFile::sendfile header=\n".$this->headers, LOG_DEBUG);
//dol_syslog("CMailFile::sendfile message=\n".$message);
// If Windows, sendmail_from must be defined
if (isset($_SERVER["WINDIR"]))
{
if (empty($this->addr_from)) $this->addr_from = 'robot@mydomain.com';
@ini_set('sendmail_from',$this->getValidAddress($this->addr_from,2));
}
// Forcage parametres
if (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)) ini_set('SMTP',$conf->global->MAIN_MAIL_SMTP_SERVER);
if (! empty($conf->global->MAIN_MAIL_SMTP_PORT)) ini_set('smtp_port',$conf->global->MAIN_MAIL_SMTP_PORT);
dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port'), LOG_DEBUG);
$this->message=stripslashes($this->message);
if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
$res = $this->simplemail->sendmail();
if (! $res)
{
$this->error="Failed to send mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."<br>Check your server logs and your firewalls setup";
dol_syslog("CMailFile::sendfile: mail end error ".$this->error, LOG_ERR);
dol_syslog("CMailFile::sendfile: ".$this->simplemail->error_log, LOG_ERR);
}
else
{
dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG);
dol_syslog("CMailFile::sendfile: ".$this->simplemail->error_log, LOG_DEBUG);
}
if (isset($_SERVER["WINDIR"]))
{
@ini_restore('sendmail_from');
}
// Forcage parametres
if (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)) ini_restore('SMTP');
if (! empty($conf->global->MAIN_MAIL_SMTP_PORT)) ini_restore('smtp_port');
}
*/
else if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment