diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 18c0273ed89..29c1912c696 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -751,6 +751,7 @@ else
$formmail->withcancel=1;
$formmail->withdeliveryreceipt=1;
$formmail->withfckeditor=1;
+ $formmail->ckeditortoolbar='dolibarr_mailings';
// Tableau des substitutions
$formmail->substit=$substitutionarrayfortest;
// Tableau des parametres complementaires du post
diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php
index 0443dfb4620..eff0c08b2cc 100644
--- a/htdocs/comm/mailing/fiche.php
+++ b/htdocs/comm/mailing/fiche.php
@@ -369,7 +369,7 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes')
dol_syslog($db->error());
dol_print_error($db);
}
-
+
$action = '';
}
}
@@ -561,7 +561,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes')
if ($object->id > 0)
{
$object->valid($user);
-
+
$_SESSION['DolMessage']='
'.$langs->trans("MailingSuccessfullyValidated").'
';
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -650,7 +650,7 @@ if ($action == 'create')
print '| '.$langs->trans("MailTitle").' | |
';
print '| '.$langs->trans("MailFrom").' | |
';
print '| '.$langs->trans("MailErrorsTo").' | |
';
-
+
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@@ -664,7 +664,7 @@ if ($action == 'create')
print ''."\n";
}
}
-
+
print '';
print '
';
@@ -773,12 +773,12 @@ else
// From
print '| '.$form->editfieldkey("MailFrom",'email_from',$object->email_from,$object,$user->rights->mailing->creer && $object->statut < 3,'string').' | ';
- print $form->editfieldval("MailFrom",'email_from',$object->email_from,$object,$user->rights->mailing->creer && $object->statut < 3,'email');
+ print $form->editfieldval("MailFrom",'email_from',$object->email_from,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
print ' |
';
// Errors to
print '| '.$form->editfieldkey("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string').' | ';
- print $form->editfieldval("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'email');
+ print $form->editfieldval("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
print ' |
';
// Status
@@ -808,7 +808,7 @@ else
print $nbemail;
}
print '';
-
+
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@@ -860,7 +860,7 @@ else
}
//print ''.$langs->trans("PreviewMailing").'';
-
+
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send)
{
print ''.$langs->trans("TestMailing").'';
@@ -1042,7 +1042,7 @@ else
print $nbemail;
}
print '';
-
+
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 1074faca6db..13eb54ac49e 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -664,17 +664,14 @@ class CMailFile
$out='';
+ $out.= "--" . $this->mixed_boundary . $this->eol;
+
if ($this->atleastoneimage)
{
- $out.= "--" . $this->mixed_boundary . $this->eol;
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
$out.= $this->eol;
$out.= "--" . $this->alternative_boundary . $this->eol;
}
- else
- {
- $out.= "--" . $this->mixed_boundary . $this->eol;
- }
if ($this->msgishtml)
{
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 01893919e00..b31d36406f5 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -597,6 +597,8 @@ class FormMail
}
else
{
+ if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
+
if(! empty($conf->global->MAIL_USE_SIGN) && $this->fromid > 0)
{
$fuser=new User($this->db);
@@ -609,7 +611,7 @@ class FormMail
// Editor wysiwyg
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
- $doleditor=new DolEditor('message',$defaultmessage,'',280,'dolibarr_notes','In',true,false,$this->withfckeditor,8,72);
+ $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$out.= $doleditor->Create(1);
}
$out.= "\n";
diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php
index d420062d118..5398825a044 100755
--- a/htdocs/core/class/smtps.class.php
+++ b/htdocs/core/class/smtps.class.php
@@ -165,6 +165,16 @@ class SMTPs
*/
var $_smtpsBoundary = null;
+ /**
+ * Related Boundary
+ */
+ var $_smtpsRelatedBoundary = null;
+
+ /**
+ * Alternative Boundary
+ */
+ var $_smtpsAlternativeBoundary = null;
+
/**
* Determines the method inwhich the message are to be sent.
* - 'sockets' [0] - conect via network to SMTP server - default
@@ -1202,13 +1212,22 @@ class SMTPs
* TODO Investigate "nested" boundary message parts
*/
//$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
- $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary() . '"' . "\r\n";
+ $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n";
// . "\r\n"
// . 'This is a multi-part message in MIME format.' . "\r\n";
$content .= "Content-Transfer-Encoding: 8bit\r\n";
$content .= "\r\n";
+ $content .= "--" . $this->_getBoundary('mixed') . "\r\n";
+
+ if (key_exists('image', $this->_msgContent))
+ {
+ $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
+ $content .= "\r\n";
+ $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
+ }
+
// Loop through message content array
foreach ($this->_msgContent as $type => $_content )
{
@@ -1217,7 +1236,7 @@ class SMTPs
// loop through all attachments
foreach ( $_content as $_file => $_data )
{
- $content .= "--" . $this->_getBoundary() . "\r\n"
+ $content .= "--" . $this->_getBoundary('mixed') . "\r\n"
. 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n"
. 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n"
. 'Content-Transfer-Encoding: base64' . "\r\n"
@@ -1235,7 +1254,7 @@ class SMTPs
// loop through all images
foreach ( $_content as $_image => $_data )
{
- $content .= "--" . $this->_getBoundary() . "\r\n";
+ $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image
$content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n"
. 'Content-Transfer-Encoding: base64' . "\r\n"
@@ -1248,11 +1267,25 @@ class SMTPs
$content .= "\r\n"
. $_data['data'] . "\r\n";
}
+
+ // always end related and end alternative after inline images
+ $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
+ $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
+ $content.= "\r\n";
}
else
{
- $content .= "--" . $this->_getBoundary() . "\r\n"
- . 'Content-Type: ' . $_content['mimeType'] . '; '
+ if (key_exists('image', $this->_msgContent))
+ {
+ $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
+ $content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message
+ $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
+ $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
+ $content.= "\r\n";
+ $content.= "--" . $this->_getBoundary('related') . "\r\n";
+ }
+
+ $content .= 'Content-Type: ' . $_content['mimeType'] . '; '
// . 'charset="' . $this->getCharSet() . '"';
. 'charset=' . $this->getCharSet() . '';
@@ -1273,7 +1306,7 @@ class SMTPs
// Close message boundries
// $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
- $content .= "--" . $this->_getBoundary() . '--' . "\r\n" ;
+ $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ;
}
return $content;
@@ -1457,6 +1490,8 @@ class SMTPs
function _setBoundary()
{
$this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
+ $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"));
+ $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"));
}
/**
@@ -1464,9 +1499,11 @@ class SMTPs
*
* @return string $_smtpsBoundary MIME message Boundary
*/
- function _getBoundary()
+ function _getBoundary($type='mixed')
{
- return $this->_smtpsBoundary;
+ if ($type == 'mixed') return $this->_smtpsBoundary;
+ else if ($type == 'related') return $this->_smtpsRelatedBoundary;
+ else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary;
}
/**