当前位置: 首页>>代码示例>>PHP>>正文


PHP CMailFile::sendfile方法代码示例

本文整理汇总了PHP中CMailFile::sendfile方法的典型用法代码示例。如果您正苦于以下问题:PHP CMailFile::sendfile方法的具体用法?PHP CMailFile::sendfile怎么用?PHP CMailFile::sendfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMailFile的用法示例。


在下文中一共展示了CMailFile::sendfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dolGetFirstLastname

            // Subject
            $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
            if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
                $societeName = $conf->global->MAIN_APPLICATION_TITLE;
            }
            $subject = $societeName . " - " . $langs->transnoentitiesnoconv("HolidaysCanceled");
            // Content
            $message = $langs->transnoentitiesnoconv("Hello") . " " . $destinataire->firstname . ",\n";
            $message .= "\n";
            $message .= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($cp->date_debut, 'day'), dol_print_date($cp->date_fin, 'day')) . "\n";
            $message .= "- " . $langs->transnoentitiesnoconv("ModifiedBy") . " : " . dolGetFirstLastname($expediteur->firstname, $expediteur->lastname) . "\n";
            $message .= "- " . $langs->transnoentitiesnoconv("Link") . " : " . $dolibarr_main_url_root . "/holiday/fiche.php?id=" . $cp->rowid . "\n\n";
            $message .= "\n";
            $mail = new CMailFile($subject, $emailTo, $emailFrom, $message);
            // Envoi du mail
            $result = $mail->sendfile();
            if (!$result) {
                header('Location: fiche.php?id=' . $_GET['id'] . '&error=mail&error_content=' . $mail->error);
                exit;
            }
            header('Location: fiche.php?id=' . $_GET['id']);
            exit;
        } else {
            // Sinon on affiche le formulaire de demande avec le message d'erreur SQL
            header('Location: fiche.php?id=' . $_GET['id'] . '&error=SQL_Create&msg=' . $cp->error);
            exit;
        }
    }
}
/*
 * View
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:fiche.php

示例2: sendMail

 /**
  * Send mail with ticket data
  * @param  $email
  * @return int 			<0 if KO; >0 if OK
  */
 public static function sendMail($email)
 {
     global $db, $conf, $langs;
     $function = "sendMail";
     require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
     if ($email["idTicket"]) {
         $ticket = new Ticket($db);
         $ticket->fetch($email["idTicket"]);
         $subject = $conf->global->MAIN_INFO_SOCIETE_NOM . ': ' . $langs->trans("CopyOfTicket") . ' ' . $ticket->ticketnumber;
         $message = self::FillMailTicketBody($ticket->id);
     }
     if ($email["idFacture"]) {
         $facture = new Facture($db);
         $facture->fetch($email["idFacture"]);
         $subject = $conf->global->MAIN_INFO_SOCIETE_NOM . ': ' . $langs->trans("CopyOfFacture") . ' ' . $facture->ref;
         $message = self::FillMailFactureBody($facture->id);
     }
     if ($email["idCloseCash"]) {
         $subject = $conf->global->MAIN_INFO_SOCIETE_NOM . ': ' . $langs->trans("CopyOfCloseCash") . ' ' . $email["idCloseCash"];
         $message = self::FillMailCloseCashBody($email["idCloseCash"]);
     }
     $from = $conf->global->MAIN_INFO_SOCIETE_NOM . "<" . $conf->global->MAIN_INFO_SOCIETE_MAIL . ">";
     $mailfile = new CMailFile($subject, $email["mail_to"], $from, $message);
     if ($mailfile->error) {
         $mesg = '<div class="error">' . $mailfile->error . '</div>';
         $res = -1;
     } else {
         $res = $mailfile->sendfile();
     }
     return ErrorControl($res, $function);
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:36,代码来源:pos.class.mañanero.php

示例3: send


//.........这里部分代码省略.........
                             $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                             break;
                         case 'ORDER_SUPPLIER_REFUSE':
                             $link = '/fourn/commande/card.php?id=' . $object->id;
                             $dir_output = $conf->fournisseur->dir_output . '/commande/';
                             $object_type = 'order_supplier';
                             $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                             $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($langs));
                             $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                             break;
                         case 'SHIPPING_VALIDATE':
                             $dir_output = $conf->expedition->dir_output . '/sending/';
                             $object_type = 'order_supplier';
                             $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref);
                             break;
                     }
                     $ref = dol_sanitizeFileName($newref);
                     $pdf_path = $dir_output . "/" . $ref . "/" . $ref . ".pdf";
                     if (!dol_is_file($pdf_path)) {
                         // We can't add PDF as it is not generated yet.
                         $filepdf = '';
                     } else {
                         $filepdf = $pdf_path;
                     }
                     $subject = '[' . $application . '] ' . $outputlangs->transnoentitiesnoconv("DolibarrNotification");
                     $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name) . "\n";
                     $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name) . "\n";
                     $message .= "\n";
                     $message .= $mesg;
                     if ($link) {
                         $message = dol_concatdesc($message, $urlwithroot . $link);
                     }
                     $mailfile = new CMailFile($subject, $sendto, $replyto, $message, array($file), array($mimefile), array($filename[count($filename) - 1]), '', '', 0, -1);
                     if ($mailfile->sendfile()) {
                         $sql = "INSERT INTO " . MAIN_DB_PREFIX . "notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, objet_id, email)";
                         $sql .= " VALUES ('" . $this->db->idate(dol_now()) . "', " . $notifcodedefid . ", " . $object->socid . ", " . $obj->cid . ", '" . $obj->type . "', '" . $object_type . "', " . $object->id . ", '" . $this->db->escape($obj->email) . "')";
                         if (!$this->db->query($sql)) {
                             dol_print_error($this->db);
                         }
                     } else {
                         $error++;
                         $this->errors[] = $mailfile->error;
                     }
                 } else {
                     dol_syslog("No notification sent for " . $sendto . " because email is empty");
                 }
                 $i++;
             }
         } else {
             dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = " . $object->socid);
         }
     } else {
         $error++;
         $this->errors[] = $this->db->lasterror();
         return -1;
     }
     // Check notification using fixed email
     if (!$error) {
         foreach ($conf->global as $key => $val) {
             if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_' . $notifcode . '_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
                 continue;
             }
             $threshold = (double) $reg[1];
             if ($object->total_ht <= $threshold) {
                 dol_syslog("A notification is requested for notifcode = " . $notifcode . " but amount = " . $object->total_ht . " so lower than threshold = " . $threshold . ". We discard this notification");
                 continue;
开发者ID:Samara94,项目名称:dolibarr,代码行数:67,代码来源:notify.class.php

示例4: Translate

 /**
  *  Send new password by email
  *
  *  @param	User	$user           Object user that send email
  *  @param	string	$password       New password
  *	@param	int		$changelater	1=Change password only after clicking on confirm email
  *  @return int 		            < 0 si erreur, > 0 si ok
  */
 function send_password($user, $password = '', $changelater = 0)
 {
     global $conf, $langs;
     global $dolibarr_main_url_root;
     require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
     $msgishtml = 0;
     // Define $msg
     $mesg = '';
     $outputlangs = new Translate("", $conf);
     if (isset($this->conf->MAIN_LANG_DEFAULT) && $this->conf->MAIN_LANG_DEFAULT != 'auto') {
         // If user has defined its own language (rare because in most cases, auto is used)
         $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
     } else {
         // If user has not defined its own language, we used current language
         $outputlangs = $langs;
     }
     $outputlangs->load("main");
     $outputlangs->load("errors");
     $outputlangs->load("users");
     $outputlangs->load("other");
     $subject = $outputlangs->transnoentitiesnoconv("SubjectNewPassword");
     // Define $urlwithroot
     //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
     //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
     $urlwithroot = DOL_MAIN_URL_ROOT;
     // This is to use same domain name than current
     if (!$changelater) {
         $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . ".\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs") . " :\n\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
         $mesg .= "\n";
         $url = $urlwithroot . '/';
         $mesg .= $outputlangs->transnoentitiesnoconv("ClickHereToGoTo", $conf->global->MAIN_APPLICATION_TITLE) . ': ' . $url . "\n\n";
         $mesg .= "--\n";
         $mesg .= $user->getFullName($outputlangs);
         // Username that make then sending
     } else {
         $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyWillBe") . " :\n\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
         $mesg .= "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("YouMustClickToChange") . " :\n";
         $url = $urlwithroot . '/user/passwordforgotten.php?action=validatenewpassword&username=' . $this->login . "&passwordhash=" . dol_hash($password);
         $mesg .= $url . "\n\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("ForgetIfNothing") . "\n\n";
         dol_syslog(get_class($this) . "::send_password url=" . $url);
     }
     $mailfile = new CMailFile($subject, $this->email, $conf->notification->email_from, $mesg, array(), array(), array(), '', '', 0, $msgishtml);
     if ($mailfile->sendfile()) {
         return 1;
     } else {
         $langs->trans("errors");
         $this->error = $langs->trans("ErrorFailedToSendPassword") . ' ' . $mailfile->error;
         return -1;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:66,代码来源:user.class.php

示例5: send

 /**
  *    	\brief      Check if notification are active for couple action/company.
  * 					If yes, send mail and save trace into llx_notify.
  * 		\param		action		Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
  * 		\param		socid		Id of third party
  * 		\param		texte		Message to send
  * 		\param		objet_type	Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
  * 		\param		objet_id	Id of object the notification deals on
  * 		\param		file		Attach a file
  *		\return		int			<0 if KO, or number of changes if OK
  */
 function send($action, $socid, $texte, $objet_type, $objet_id, $file = "")
 {
     global $conf, $langs, $mysoc, $dolibarr_main_url_root;
     $langs->load("other");
     dol_syslog("Notify::send action={$action}, socid={$socid}, texte={$texte}, objet_type={$objet_type}, objet_id={$objet_id}, file={$file}");
     $sql = "SELECT s.nom, c.email, c.rowid as cid, c.name, c.firstname,";
     $sql .= " a.rowid as adid, a.label, a.code, n.rowid";
     $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c,";
     $sql .= " " . MAIN_DB_PREFIX . "c_action_trigger as a,";
     $sql .= " " . MAIN_DB_PREFIX . "notify_def as n,";
     $sql .= " " . MAIN_DB_PREFIX . "societe as s";
     $sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
     $sql .= " AND n.fk_soc = s.rowid";
     if (is_numeric($action)) {
         $sql .= " AND n.fk_action = " . $action;
     } else {
         $sql .= " AND a.code = '" . $action . "'";
     }
     // New usage
     $sql .= " AND s.rowid = " . $socid;
     dol_syslog("Notify::send sql=" . $sql);
     $result = $this->db->query($sql);
     if ($result) {
         $num = $this->db->num_rows($result);
         $i = 0;
         while ($i < $num) {
             $obj = $this->db->fetch_object($result);
             $sendto = $obj->firstname . " " . $obj->name . " <" . $obj->email . ">";
             $actiondefid = $obj->adid;
             if (dol_strlen($sendto)) {
                 include_once DOL_DOCUMENT_ROOT . '/lib/files.lib.php';
                 $application = $conf->global->MAIN_APPLICATION_TITLE ? $conf->global->MAIN_APPLICATION_TITLE : 'Dolibarr ERP/CRM';
                 $subject = '[' . $application . '] ' . $langs->transnoentitiesnoconv("DolibarrNotification");
                 $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name) . "\n";
                 $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name) . "\n";
                 $message .= "\n";
                 $message .= $texte;
                 // Add link
                 switch ($objet_type) {
                     case 'ficheinter':
                         $link = DOL_URL_ROOT . '/fichinter/fiche.php?id=' . $objet_id;
                         break;
                     case 'propal':
                         $link = DOL_URL_ROOT . '/comm/propal.php?id=' . $objet_id;
                         break;
                     case 'facture':
                         $link = DOL_URL_ROOT . '/compta/facture.php?facid=' . $objet_id;
                         break;
                     case 'order':
                         $link = DOL_URL_ROOT . '/commande/fiche.php?facid=' . $objet_id;
                         break;
                     case 'order_supplier':
                         $link = DOL_URL_ROOT . '/fourn/commande/fiche.php?facid=' . $objet_id;
                         break;
                 }
                 $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $dolibarr_main_url_root);
                 if ($link) {
                     $message .= "\n" . $urlwithouturlroot . $link;
                 }
                 $filename = basename($file);
                 $mimefile = dol_mimetype($file);
                 $msgishtml = 0;
                 $replyto = $conf->notification->email_from;
                 $mailfile = new CMailFile($subject, $sendto, $replyto, $message, array($file), array($mimefile), array($filename[sizeof($filename) - 1]), '', '', 0, $msgishtml);
                 if ($mailfile->sendfile()) {
                     $sendto = htmlentities($sendto);
                     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "notify (daten, fk_action, fk_contact, objet_type, objet_id, email)";
                     $sql .= " VALUES (" . $this->db->idate(mktime()) . ", " . $actiondefid . " ," . $obj->cid . " , '" . $objet_type . "', " . $objet_id . ", '" . $this->db->escape($obj->email) . "')";
                     dol_syslog("Notify::send sql=" . $sql);
                     if (!$this->db->query($sql)) {
                         dol_print_error($this->db);
                     }
                 } else {
                     $this->error = $mailfile->error;
                     //dol_syslog("Notify::send ".$this->error, LOG_ERR);
                 }
             }
             $i++;
         }
         return $i;
     } else {
         $this->error = $this->db->error();
         return -1;
     }
 }
开发者ID:netors,项目名称:dolibarr,代码行数:96,代码来源:notify.class.php

示例6: _createEvent

                        if (!is_array($val) && !is_object($val)) {
                            $TSearch[] = $prefix . $attr;
                            $TVal[] = $val;
                        }
                    }
                    //Changement de méthode (pas de str_replace) pour éviter les collisions. Exemple avec __PROPAL_ref et __PROPAL_ref_client
                    foreach ($TSearchPropal as $i => $propal_value) {
                        $msg = preg_replace('/' . $propal_value . '\\b/', $TValPropal[$i], $msg);
                    }
                    $msg = preg_replace('/__SIGNATURE__\\b/', $newUser->signature, $msg);
                    $msg = str_replace($TSearch, $TVal, $msg);
                    $TMail[] = $mail;
                    // Construct mail
                    $CMail = new CMailFile($subject, $mail, $conf->global->MAIN_MAIL_EMAIL_FROM, $msg, $filename_list, $mimetype_list, $mimefilename_list, '', '', '', $msgishtml, $conf->global->MAIN_MAIL_ERRORS_TO);
                    // Send mail
                    $CMail->sendfile();
                    if ($CMail->error) {
                        $TErrorMail[] = $CMail->error;
                    } else {
                        _createEvent($db, $user, $langs, $conf, $propal, 0, $conf->global->PROPALAUTOSEND_MSG_SUBJECT, $msg);
                    }
                }
            }
        }
    }
    echo "liste des mails ok : ";
    var_dump($TMail);
    echo "<br />liste des mails en erreur : ";
    var_dump($TErrorMail);
}
function _createEvent(&$db, &$user, &$langs, &$conf, &$propal, $fk_socpeople, $subject, $message, $type = 'thirdparty')
开发者ID:ATM-Consulting,项目名称:dolibarr_module_propalautosend,代码行数:31,代码来源:propalAutoSend.php

示例7: testCMailFileText

 /**
  * testCMailFileText
  *
  * @return void
  */
 public function testCMailFileText()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new CMailFile('Test', 'test@test.com', 'from@from.com', 'Message txt', array(), array(), array(), '', '', 1, 0);
     $result = $localobject->sendfile();
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertFalse($result);
     // False because mail send disabled
     return $result;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:19,代码来源:CMailFileTest.php

示例8: envoi_mail

/**
 * 	Send email
 *
 * 	@param	string	$mode					Mode (test | confirm)
 *  @param	string	$oldemail				Old email
 * 	@param	string	$message				Message to send
 * 	@param	string	$total					Total amount of unpayed invoices
 *  @param	string	$userlang				Code lang to use for email output.
 *  @param	string	$oldsalerepresentative	Old sale representative
 * 	@return	int								<0 if KO, >0 if OK
 */
function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldsalerepresentative)
{
    global $conf, $langs;
    if (getenv('DOL_FORCE_EMAIL_TO')) {
        $oldemail = getenv('DOL_FORCE_EMAIL_TO');
    }
    $newlangs = new Translate('', $conf);
    $newlangs->setDefaultLang(empty($userlang) ? empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT : $userlang);
    $newlangs->load("main");
    $newlangs->load("bills");
    $subject = empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT;
    $sendto = $oldemail;
    $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
    $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
    $msgishtml = -1;
    print "- Send email for " . $oldsalerepresentative . " (" . $oldemail . "), total: " . $total . "\n";
    dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to " . $oldemail);
    $usehtml = 0;
    if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) {
        $usehtml += 1;
    }
    if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) {
        $usehtml += 1;
    }
    $allmessage = '';
    if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) {
        $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER;
    } else {
        $allmessage .= $newlangs->transnoentities("ListOfYourUnpaidInvoices") . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
        $allmessage .= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices") . ($usehtml ? "<br>\n" : "\n");
    }
    $allmessage .= $message . ($usehtml ? "<br>\n" : "\n");
    $allmessage .= $langs->trans("Total") . " = " . price($total, 0, $newlangs, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n");
    if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) {
        $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER;
        if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) {
            $usehtml += 1;
        }
    }
    $mail = new CMailFile($subject, $sendto, $from, $allmessage, array(), array(), array(), '', '', 0, $msgishtml);
    $mail->errors_to = $errorsto;
    // Send or not email
    if ($mode == 'confirm') {
        $result = $mail->sendfile();
        if (!$result) {
            print "Error sending email " . $mail->error . "\n";
            dol_syslog("Error sending email " . $mail->error . "\n");
        }
    } else {
        print "No email sent (test mode)\n";
        dol_syslog("No email sent (test mode)");
        $mail->dump_mail();
        $result = 1;
    }
    if ($result) {
        return 1;
    } else {
        return -1;
    }
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:71,代码来源:email_unpaid_invoices_to_representatives.php

示例9: envoi_mail

/**
 * 	Send email
 *
 * 	@param	string	$mode			Mode (test | confirm)
 *  @param	string	$oldemail		Target email
 * 	@param	string	$message		Message to send
 * 	@param	string	$total			Total amount of unpayed invoices
 *  @param	string	$userlang		Code lang to use for email output.
 *  @param	string	$oldtarget		Target name
 * 	@return	int						<0 if KO, >0 if OK
 */
function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget)
{
    global $conf, $langs;
    if (getenv('DOL_FORCE_EMAIL_TO')) {
        $oldemail = getenv('DOL_FORCE_EMAIL_TO');
    }
    $newlangs = new Translate('', $conf);
    $newlangs->setDefaultLang(empty($userlang) ? empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT : $userlang);
    $newlangs->load("main");
    $newlangs->load("bills");
    $subject = empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT;
    $sendto = $oldemail;
    $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
    $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
    $msgishtml = -1;
    print "- Send email to '" . $oldtarget . "' (" . $oldemail . "), total: " . $total . "\n";
    dol_syslog("email_unpaid_invoices_to_customers.php: send mail to " . $oldemail);
    $usehtml = 0;
    if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) {
        $usehtml += 1;
    }
    if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) {
        $usehtml += 1;
    }
    $allmessage = '';
    if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) {
        $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER;
    } else {
        $allmessage .= "Dear customer" . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
        $allmessage .= "Please, find a summary of the bills with pending payments from you." . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
        $allmessage .= "Note: This list contains only unpaid invoices." . ($usehtml ? "<br>\n" : "\n");
    }
    $allmessage .= $message . ($usehtml ? "<br>\n" : "\n");
    $allmessage .= $langs->trans("Total") . " = " . price($total, 0, $userlang, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n");
    if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) {
        $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER;
        if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) {
            $usehtml += 1;
        }
    }
    $mail = new CMailFile($subject, $sendto, $from, $allmessage, array(), array(), array(), '', '', 0, $msgishtml);
    $mail->errors_to = $errorsto;
    // Send or not email
    if ($mode == 'confirm') {
        $result = $mail->sendfile();
        if (!$result) {
            print "Error sending email " . $mail->error . "\n";
            dol_syslog("Error sending email " . $mail->error . "\n");
        }
    } else {
        print "No email sent (test mode)\n";
        dol_syslog("No email sent (test mode)");
        $mail->dump_mail();
        $result = 1;
    }
    unset($newlangs);
    if ($result) {
        return 1;
    } else {
        return -1;
    }
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:73,代码来源:email_unpaid_invoices_to_customers.php

示例10: envoi_mail

/**
 * 	Send email
 *
 * 	@param	string	$oldemail	Old email
 * 	@param	string	$message	Message to send
 * 	@param	string	$total		Total amount of unpayed invoices
 * 	@return	int					<0 if KO, >0 if OK
 */
function envoi_mail($oldemail,$message,$total)
{
    global $conf,$langs;

    $subject = "[Dolibarr] List of unpaid invoices";
    $sendto = $oldemail;
    $from = $conf->global->MAIN_EMAIL_FROM;
    $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
	$msgishtml = 0;

    print "Envoi mail pour $oldemail, total: $total\n";
    dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to $oldemail");

    $allmessage = "List of unpaid invoices\n";
    $allmessage .= "This list contains only invoices for third parties you are linked to as a sales representative.\n";
    $allmessage .= "\n";
    $allmessage .= $message;
    $allmessage .= "\n";
    $allmessage .= $langs->trans("Total")." = ".price($total)."\n";

    $mail = new CMailFile(
        $subject,
        $sendto,
        $from,
        $allmessage,
        array(),
        array(),
        array(),
        '',
        '',
        0,
        $msgishtml
    );

    $mail->errors_to = $errorsto;

    $result=$mail->sendfile();
    if ($result)
    {
        return 1;
    }
    else
    {
        return -1;
    }
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:54,代码来源:email_unpaid_invoices_to_representatives.php

示例11: envoi_mail

/**
 * 	Send email
 *
 * 	@param	string	$mode			Mode (test | confirm)
 *  @param	string	$oldemail		Target email
 * 	@param	string	$message		Message to send
 * 	@param	string	$total			Total amount of unpayed invoices
 *  @param	string	$userlang		Code lang to use for email output.
 *  @param	string	$oldtarget		Target name
 *  @param  int		$duration_value	duration value
 * 	@return	int						<0 if KO, >0 if OK
 */
function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value)
{
    global $conf, $langs;
    if (getenv('DOL_FORCE_EMAIL_TO')) {
        $oldemail = getenv('DOL_FORCE_EMAIL_TO');
    }
    $newlangs = new Translate('', $conf);
    $newlangs->setDefaultLang(empty($userlang) ? empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT : $userlang);
    $newlangs->load("main");
    $newlangs->load("contracts");
    if ($duration_value) {
        if ($duration_value > 0) {
            $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value);
        } else {
            $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value);
        }
    } else {
        $title = $newlangs->transnoentities("ListOfServicesToExpire");
    }
    $subject = empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT) ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT;
    $sendto = $oldemail;
    $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
    $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
    $msgishtml = -1;
    print "- Send email to '" . $oldtarget . "' (" . $oldemail . "), total: " . $total . "\n";
    dol_syslog("email_expire_services_to_customers.php: send mail to " . $oldemail);
    $usehtml = 0;
    if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) {
        $usehtml += 1;
    }
    if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER)) {
        $usehtml += 1;
    }
    $allmessage = '';
    if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER)) {
        $allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER;
    } else {
        $allmessage .= "Dear customer" . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
        $allmessage .= "Please, find a summary of the services contracted by you that are about to expire." . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
    }
    $allmessage .= $message . ($usehtml ? "<br>\n" : "\n");
    //$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
    if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) {
        $allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER;
        if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) {
            $usehtml += 1;
        }
    }
    $mail = new CMailFile($subject, $sendto, $from, $allmessage, array(), array(), array(), '', '', 0, $msgishtml);
    $mail->errors_to = $errorsto;
    // Send or not email
    if ($mode == 'confirm') {
        $result = $mail->sendfile();
        if (!$result) {
            print "Error sending email " . $mail->error . "\n";
            dol_syslog("Error sending email " . $mail->error . "\n");
        }
    } else {
        print "No email sent (test mode)\n";
        dol_syslog("No email sent (test mode)");
        $mail->dump_mail();
        $result = 1;
    }
    unset($newlangs);
    if ($result) {
        return 1;
    } else {
        return -1;
    }
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:82,代码来源:email_expire_services_to_customers.php

示例12: _sendByMail

function _sendByMail(&$db, &$conf, &$user, &$langs, &$facture, &$societe, $label)
{
    $filename_list = array();
    $mimetype_list = array();
    $mimefilename_list = array();
    $ref = dol_sanitizeFileName($facture->ref);
    $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/') . '([^\\-])+');
    $file = $fileparams['fullname'];
    // Build document if it not exists
    if (!$file || !is_readable($file)) {
        $result = $facture->generateDocument($facture->modelpdf, $langs, 0, 0, 0);
        if ($result <= 0) {
            $error = 1;
            return $error;
        }
    }
    $label = !empty($conf->global->SENDINVOICETOADHERENT_SUBJECT) ? $conf->global->SENDINVOICETOADHERENT_SUBJECT : $label;
    $substitutionarray = array('__NAME__' => $societe->name, '__REF__' => $facture->ref);
    $message = $conf->global->SENDINVOICETOADHERENT_MESSAGE;
    $message = make_substitutions($message, $substitutionarray);
    $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/') . '([^\\-])+');
    $file = $fileparams['fullname'];
    $filename = basename($file);
    $mimefile = dol_mimetype($file);
    $filename_list[] = $file;
    $mimetype_list[] = $mimefile;
    $mimefilename_list[] = $filename;
    $CMail = new CMailFile($label, $societe->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $message, $filename_list, $mimetype_list, $mimefilename_list, '', '', '', '', $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO);
    // Send mail
    return $CMail->sendfile();
}
开发者ID:ATM-Consulting,项目名称:dolibarr_module_sendinvoicetoadherent,代码行数:31,代码来源:sendinvoicetoadherent.php

示例13: sendNotification

 /**
  *@desc Envoi de la notification
  *@param 
  *       $mailSubject : Objet de l'email
  *       $toNumber : destinatires (email et numéro de fax séparés par des virgules)
  *       $filename : nom du fichier à envoyer
  *       $bodyMessage : corps du message email
  *@author tpi
  *@return      
  *        boolean
  *@comment           
  */  
 function sendNotification($htmlContent, $mailSubject, $recipients, $filename, $bodyMessage,$ajax)
 {
   $ajax->addLog("sendNotification(\$htmlContent, $mailSubject, $recipients, $filename, \$bodyMessage)",INFO);
   require_once(dirname(__FILE__) ."/CMailFile.php3");
   try
   {
     $htmlTemp = tempnam("/tmp","htmlDocGfpc");
     $tmpHandle = fopen($htmlTemp,"w");
     fwrite($tmpHandle,$htmlContent);
     fclose($tmpHandle);
     
     # Tell HTMLDOC not to run in CGI mode...
     putenv("HTMLDOC_NOCGI=1");
     //Generation et affichage sur la sortie standard
     //$cmd = "htmldoc -f $filename -t pdf --quiet --color --webpage --jpeg  --left 30 --top 20 --bottom 20 --right 20 --footer c.: --fontsize 10 --textfont {helvetica}";
     $cmd = "htmldoc -t pdf --quiet --color --webpage --jpeg  --left 30 --top 20 --bottom 20 --right 20 --footer c.: --fontsize 10 --textfont {helvetica}";
     ob_start();
     $err = passthru("$cmd '$htmlTemp'");
     $content = ob_get_contents();
     ob_end_clean();
     $tmpHandle = fopen("/tmp/".$filename,"w");
     fwrite($tmpHandle,$content);
     fclose($tmpHandle);
     unlink($htmlTemp);
     
     if($err!=0){
       throw new Exception("HTMLDOC error with code '$err'.");
     }
     
     $newmail = new CMailFile($mailSubject,$recipients,"svp.clinical@businessdecision.com",utf8_decode($bodyMessage),dirname(__FILE__)."/tmp/$filename","application/octet-stream",$filename);
     $newmail->sendfile();
     
     $ajax->addLog("Notification sent : $mailSubject",INFO);
     return true;
   }
   catch(Exception $e)
   {
     $str= "Error while sending a notification (".$filename.") : Line ". $e->getLine() ." - ". $e->getMessage() ." (". __METHOD__ .")";
     $ajax->addLog($str,ERROR);
     return false;
   }
 }
开发者ID:ThomasPerraudin,项目名称:ALIX-EDC-SOLUTIONS,代码行数:54,代码来源:hookFunctions.php

示例14: CMailFile

    //	$sendto = "araje@usimagingnetwork.com";
    $sendto = "lperez@usimagingnetwork.com, USI_ClaimsFinance@usimagingnetwork.com, sstough@usimagingnetwork.com";
    //$sendto = "lperez@usimagingnetwork.com";
    $subject = "Cashin By TPA Check number";
    $replyto = "webadmin@usimagingnetwork.com";
    $message = "<font face=\"sans-serif\" size=\"3\">";
    $message .= $yyyy . " Cash In by TPA Check Number. See attached file<br /><br /><br />";
    $message .= "</font>";
    $message .= "<font face=\"sans-serif\" size=\"1\">";
    $message .= $q . "<br />";
    $message .= "../plexis/getCashinByTPAchecknumber_withtotals.php<br />";
    $message .= "../plexis/getCashinByTPAchecknumber.bat<br />";
    $message .= "Job is located in scheduled tasks: getCashinByTPAchecknumber";
    $message .= "</font>";
    $filetoattach = $file;
    $mimetype = "application/vnd.ms-excel";
    $newmail = new CMailFile($subject, $sendto, $replyto, $message, $filetoattach, $mimetype);
    $newmail->sendfile();
    //move file from plexis to misc folder
    @copy($filename, "D:\\Documents\\/Misc\\/" . $file);
    if (file_exists("D:\\Documents\\/Misc\\/" . $file)) {
        unlink($filename);
    }
} else {
    $to = "USImaging_IT@usimagingnetwork.com";
    $from_mail = "USImaging_IT@usimagingnetwork.com";
    $from_name = "<US Imaging IT>";
    $replyto = "USImaging_IT@usimagingnetwork.com";
    $subject = "[Important] Cashin By TPA check date failed";
    $message = "File not found: " . $filename;
}
开发者ID:jasmith152,项目名称:plexis,代码行数:31,代码来源:getCashinByTPAchecknumber_withtotals.php

示例15: Translate

 /**
  *   \brief     	Envoie mot de passe par mail
  *   \param     	user            Object user de l'utilisateur qui fait l'envoi
  *   \param			password        Nouveau mot de passe
  *	 \param			changelater		1=Change password only after clicking on confirm email
  *   \return    	int             < 0 si erreur, > 0 si ok
  */
 function send_password($user, $password = '', $changelater = 0)
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . "/lib/CMailFile.class.php";
     $subject = $langs->trans("SubjectNewPassword");
     $msgishtml = 0;
     // Define $msg
     $mesg = '';
     $outputlangs = new Translate("", $conf);
     if (isset($this->conf->MAIN_LANG_DEFAULT) && $this->conf->MAIN_LANG_DEFAULT != 'auto') {
         // If user has defined its own language (rare because in most cases, auto is used)
         $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
     } else {
         // If user has not defined its own language, we used current language
         $outputlangs = $langs;
     }
     // Define urlwithouturlroot
     if (!empty($_SERVER["HTTP_HOST"])) {
         $urlwithouturlroot = 'http://' . preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $_SERVER["HTTP_HOST"]);
     } else {
         $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $dolibarr_main_url_root);
     }
     if (!empty($dolibarr_main_force_https)) {
         $urlwithouturlroot = preg_replace('/http:/i', 'https:', $urlwithouturlroot);
     }
     // TODO Use outputlangs to translate messages
     if (!$changelater) {
         $mesg .= "A request to change your Dolibarr password has been received.\n";
         $mesg .= "This is your new keys to login:\n\n";
         $mesg .= $langs->trans("Login") . " : {$this->login}\n";
         $mesg .= $langs->trans("Password") . " : {$password}\n\n";
         $mesg .= "\n";
         $url = $urlwithouturlroot . DOL_URL_ROOT;
         $mesg .= 'Click here to go to Dolibarr: ' . $url . "\n\n";
         $mesg .= "--\n";
         $mesg .= $user->getFullName($langs);
         // Username that make then sending
     } else {
         $mesg .= "A request to change your Dolibarr password has been received.\n";
         $mesg .= "Your new key to login will be:\n\n";
         $mesg .= $langs->trans("Login") . " : {$this->login}\n";
         $mesg .= $langs->trans("Password") . " : {$password}\n\n";
         $mesg .= "\n";
         $mesg .= "You must click on the folowing link to validate its change.\n";
         $url = $urlwithouturlroot . DOL_URL_ROOT . '/user/passwordforgotten.php?action=validatenewpassword&username=' . $this->login . "&passwordmd5=" . md5($password);
         $mesg .= $url . "\n\n";
         $mesg .= "If you didn't ask anything, just forget this email\n\n";
         dol_syslog("User::send_password url=" . $url);
     }
     $mailfile = new CMailFile($subject, $this->email, $conf->notification->email_from, $mesg, array(), array(), array(), '', '', 0, $msgishtml);
     if ($mailfile->sendfile()) {
         return 1;
     } else {
         $this->error = $langs->trans("ErrorFailedToSendPassword") . ' ' . $mailfile->error;
         //print nl2br($mesg);
         return -1;
     }
 }
开发者ID:netors,项目名称:dolibarr,代码行数:65,代码来源:user.class.php


注:本文中的CMailFile::sendfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。