$object->elementtype = $object->element;
     // Appel des triggers
     include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
     $interface = new Interfaces($db);
     $result = $interface->run_triggers('COMPANY_SENTBYMAIL', $object, $user, $langs, $conf);
     if ($result < 0) {
         $error++;
         $this->errors = $interface->errors;
     }
     // Fin appel triggers
     if ($error) {
         dol_print_error($db);
     } else {
         // Redirect here
         // This avoid sending mail twice if going out and then back to page
         $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
         setEventMessage($mesg);
         header('Location: ' . $_SERVER["PHP_SELF"] . '?' . ($paramname ? $paramname : 'id') . '=' . $object->id);
         exit;
     }
 } else {
     $langs->load("other");
     $mesg = '<div class="error">';
     if ($mailfile->error) {
         $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
         $mesg .= '<br>' . $mailfile->error;
     } else {
         $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
     }
     $mesg .= '</div>';
     setEventMessage($mesg, 'warnings');
Ejemplo n.º 2
0
                $filename = $attachedfiles['names'];
                $mimetype = $attachedfiles['mimes'];

                // Envoi de la propal
                require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
                $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
                if ($mailfile->error)
                {
                    $mesg='<div class="error">'.$mailfile->error.'</div>';
                }
                else
                {
                    $result=$mailfile->sendfile();
                    if ($result)
                    {
                        $mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)).'.</div>';

                        $error=0;

                        // Initialisation donnees
                        $object->sendtoid		= $sendtoid;
                        $object->actiontypecode	= $actiontypecode;
                        $object->actionmsg 		= $actionmsg;
                        $object->actionmsg2		= $actionmsg2;
                        $object->fk_element		= $object->id;
						$object->elementtype		= $object->element;

                        // Appel des triggers
                        include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                        $interface=new Interfaces($db);
                        $result=$interface->run_triggers('FICHEINTER_SENTBYMAIL',$object,$user,$langs,$conf);
Ejemplo n.º 3
0
        if (!empty($object->bgimage)) {
            $arr_css['bgimage'] = $object->bgimage;
        }
        // Attached files
        $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
        if (count($listofpaths)) {
            foreach ($listofpaths as $key => $val) {
                $arr_file[] = $listofpaths[$key]['fullname'];
                $arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
                $arr_name[] = $listofpaths[$key]['name'];
            }
        }
        $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css);
        $result = $mailfile->sendfile();
        if ($result) {
            $mesg = '<div class="ok">' . $langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)) . '</div>';
        } else {
            $mesg = '<div class="error">' . $langs->trans("ResultKo") . '<br>' . $mailfile->error . ' ' . $result . '</div>';
        }
        $action = '';
    }
}
// Action add emailing
if ($action == 'add') {
    $object->email_from = trim($_POST["from"]);
    $object->email_replyto = trim($_POST["replyto"]);
    $object->email_errorsto = trim($_POST["errorsto"]);
    $object->titre = trim($_POST["titre"]);
    $object->sujet = trim($_POST["sujet"]);
    $object->body = trim($_POST["body"]);
    $object->bgcolor = trim($_POST["bgcolor"]);
Ejemplo n.º 4
0
         if (!empty($object->bgimage)) {
             $arr_css['bgimage'] = $object->bgimage;
         }
         // Attached files
         $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
         if (count($listofpaths)) {
             foreach ($listofpaths as $key => $val) {
                 $arr_file[] = $listofpaths[$key]['fullname'];
                 $arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
                 $arr_name[] = $listofpaths[$key]['name'];
             }
         }
         $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css);
         $result = $mailfile->sendfile();
         if ($result) {
             setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs');
         } else {
             setEventMessages($langs->trans("ResultKo") . '<br>' . $mailfile->error . ' ' . $result, null, 'errors');
         }
         $action = '';
     }
 }
 // Action add emailing
 if ($action == 'add') {
     $mesgs = array();
     $object->email_from = trim($_POST["from"]);
     $object->email_replyto = trim($_POST["replyto"]);
     $object->email_errorsto = trim($_POST["errorsto"]);
     $object->titre = trim($_POST["titre"]);
     $object->sujet = trim($_POST["sujet"]);
     $object->body = trim($_POST["body"]);
Ejemplo n.º 5
0
    if (!$error) {
        // Le message est-il en html
        $msgishtml = 0;
        // Message is not HTML
        if ($action == 'sendhtml') {
            $msgishtml = 1;
        }
        // Force message to HTML
        // Pratique les substitutions sur le sujet et message
        $subject = make_substitutions($subject, $substitutionarrayfortest);
        $body = make_substitutions($body, $substitutionarrayfortest);
        require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
        $mailfile = new CMailFile($subject, $sendto, $email_from, $body, $filepath, $mimetype, $filename, $sendtocc, $sendtoccc, $deliveryreceipt, $msgishtml, $errors_to);
        $result = $mailfile->sendfile();
        if ($result) {
            setEventMessage($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($email_from, 2), $mailfile->getValidAddress($sendto, 2)));
        } else {
            setEventMessage($langs->trans("ResultKo") . '<br>' . $mailfile->error . ' ' . $result, 'errors');
        }
        $action = '';
    }
}
/*
 * View
 */
$linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) {
    $linuxlike = 0;
}
if (preg_match('/^mac/i', PHP_OS)) {
    $linuxlike = 0;
Ejemplo n.º 6
0
 $substitutionarray = array('__ID__' => join(', ', array_keys($listofqualifiedinvoice)), '__EMAIL__' => $thirdparty->email, '__CHECK_READ__' => '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>', '__FACREF__' => join(', ', $listofqualifiedref), '__REF__' => join(', ', $listofqualifiedref), '__REFCLIENT__' => $thirdparty->name);
 $subject = make_substitutions($subject, $substitutionarray);
 $message = make_substitutions($message, $substitutionarray);
 $filepath = $attachedfiles['paths'];
 $filename = $attachedfiles['names'];
 $mimetype = $attachedfiles['mimes'];
 //var_dump($filepath);
 // Send mail
 require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
 $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
 if ($mailfile->error) {
     $resaction .= '<div class="error">' . $mailfile->error . '</div>';
 } else {
     $result = $mailfile->sendfile();
     if ($result) {
         $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)) . '<br>';
         // Must not contain "
         $error = 0;
         // Insert logs into agenda
         foreach ($listofqualifiedinvoice as $invid => $object) {
             $actiontypecode = 'AC_FAC';
             $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
             if ($message) {
                 if ($sendtocc) {
                     $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
                 }
                 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
                 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
                 $actionmsg = dol_concatdesc($actionmsg, $message);
             }
             // Initialisation donnees
Ejemplo n.º 7
0
 /**
  * testCMailFileStatic
  *
  * @return string
  */
 public function testCMailFileStatic()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new CMailFile('', '', '', '');
     $src = 'John Doe <*****@*****.**>';
     $result = $localobject->getValidAddress($src, 0);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, 'John Doe <*****@*****.**>');
     $src = 'John Doe <*****@*****.**>';
     $result = $localobject->getValidAddress($src, 1);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, '<*****@*****.**>');
     $src = 'John Doe <*****@*****.**>';
     $result = $localobject->getValidAddress($src, 2);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, '*****@*****.**');
     $src = 'John Doe <*****@*****.**>';
     $result = $localobject->getValidAddress($src, 3, 0);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, '"John Doe" <*****@*****.**>');
     $src = 'John Doe <*****@*****.**>';
     $result = $localobject->getValidAddress($src, 3, 1);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, '"=?UTF-8?B?Sm9obiBEb2U=?=" <*****@*****.**>');
     return $result;
 }
Ejemplo n.º 8
0
                $filename = $attachedfiles['names'];
                $mimetype = $attachedfiles['mimes'];

                // Send mail
                require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
                $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
                if ($mailfile->error)
                {
                    $mesg='<div class="error">'.$mailfile->error.'</div>';
                }
                else
                {
                    $result=$mailfile->sendfile();
                    if ($result)
                    {
                        $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));	// Must not contains "

                        $error=0;

                        // Initialisation donnees
                        $object->sendtoid		= $sendtoid;
                        $object->actiontypecode	= $actiontypecode;
                        $object->actionmsg		= $actionmsg;
                        $object->actionmsg2		= $actionmsg2;
                        $object->fk_element		= $object->id;
                        $object->elementtype	= $object->element;

                        // Appel des triggers
                        include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                        $interface=new Interfaces($db);
                        $result=$interface->run_triggers('ORDER_SENTBYMAIL',$object,$user,$langs,$conf);