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


PHP SugarPHPMailer::send方法代码示例

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


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

示例1: sendSugarPHPMail

function sendSugarPHPMail($tos, $subject, $body)
{
    require_once 'include/SugarPHPMailer.php';
    require_once 'modules/Administration/Administration.php';
    global $current_user;
    $mail = new SugarPHPMailer();
    $admin = new Administration();
    $admin->retrieveSettings();
    if ($admin->settings['mail_sendtype'] == "SMTP") {
        $mail->Host = $admin->settings['mail_smtpserver'];
        $mail->Port = $admin->settings['mail_smtpport'];
        if ($admin->settings['mail_smtpauth_req']) {
            $mail->SMTPAuth = TRUE;
            $mail->Username = $admin->settings['mail_smtpuser'];
            $mail->Password = $admin->settings['mail_smtppass'];
        }
        $mail->Mailer = "smtp";
        $mail->SMTPKeepAlive = true;
    } else {
        $mail->mailer = 'sendmail';
    }
    $mail->IsSMTP();
    // send via SMTP
    if ($admin->settings['mail_smtpssl'] == '2') {
        $mail->SMTPSecure = "tls";
    } elseif ($admin->settings['mail_smtpssl'] == '1') {
        $mail->SMTPSecure = "ssl";
    }
    $mail->CharSet = 'UTF-8';
    $mail->From = $admin->settings['notify_fromaddress'];
    $mail->FromName = $admin->settings['notify_fromname'];
    $mail->ContentType = "text/html";
    //"text/plain"
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->Body = $body;
    foreach ($tos as $name => $address) {
        $mail->AddAddress("{$address}", "{$name}");
    }
    if (!$mail->send()) {
        $GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo);
        return false;
    } else {
        return true;
    }
}
开发者ID:omusico,项目名称:sugar_work,代码行数:46,代码来源:send_mail.php

示例2: sendSugarPHPMail

/**
* Created by iluxovi4 - Убирайте везде эту подпись
* Protected by SugarTalk.ru greshdrtju
=======
*/
function sendSugarPHPMail($tos, $subject, $body, $attach = "", $nameToSend = "", $assigned_user_id, $type)
{
    require_once 'include/SugarPHPMailer.php';
    require_once 'modules/Administration/Administration.php';
    global $current_user;
    $mail = new SugarPHPMailer();
    $admin = new Administration();
    $admin->retrieveSettings();
    $user = new User();
    if ($type == 'Realty') {
        $user_id = $assigned_user_id;
        $user->retrieve($user_id);
        $oe = new OutboundEmail();
        $userSettings = $oe->getUserMailerSettings($user);
        if ($admin->settings['mail_sendtype'] == "SMTP") {
            $mail->Host = $admin->settings['mail_smtpserver'];
            $mail->Port = $admin->settings['mail_smtpport'];
            if ($admin->settings['mail_smtpauth_req']) {
                $mail->SMTPAuth = TRUE;
                $mail->Username = $admin->settings['mail_smtpuser'];
                $mail->Password = $admin->settings['mail_smtppass'];
            }
            $mail->Mailer = "smtp";
            $mail->SMTPKeepAlive = true;
        } else {
            $mail->mailer = 'sendmail';
        }
        $mail->IsSMTP();
        // send via SMTP
        if ($admin->settings['mail_smtpssl'] == '2') {
            $mail->SMTPSecure = "tls";
        } elseif ($admin->settings['mail_smtpssl'] == '1') {
            $mail->SMTPSecure = "ssl";
        }
        //$mail->Body = $body."<br/> <b style='color: red;'><strong> Важно! </strong> Ответ присылайте на почту: </b>".$userSettings->mail_smtpuser;
        $mail->Body = $body;
        $mail->From = $admin->settings['notify_fromaddress'];
    } elseif ($type == 'Contacts' or $type == 'Accounts') {
        $user_id = $assigned_user_id;
        $user->retrieve($user_id);
        $oe = new OutboundEmail();
        $userSettings = $oe->getUserMailerSettings($user);
        if ($userSettings->mail_sendtype == "SMTP") {
            $mail->Host = $admin->settings['mail_smtpserver'];
            $mail->Port = $admin->settings['mail_smtpport'];
            if ($userSettings->mail_smtpauth_req) {
                $mail->SMTPAuth = TRUE;
                $mail->Username = $userSettings->mail_smtpuser;
                $mail->Password = $userSettings->mail_smtppass;
            }
            $mail->Mailer = "smtp";
            $mail->SMTPKeepAlive = true;
        } else {
            $mail->mailer = 'sendmail';
        }
        $mail->IsSMTP();
        // send via SMTP
        if ($admin->settings['mail_smtpssl'] == '2') {
            $mail->SMTPSecure = "tls";
        } elseif ($admin->settings['mail_smtpssl'] == '1') {
            $mail->SMTPSecure = "ssl";
        }
        $mail->Body = $body;
        $mail->From = $user->email1;
    }
    //$user->retrieve();
    $mail->CharSet = 'UTF-8';
    $mail->FromName = $admin->settings['notify_fromname'];
    $mail->ContentType = "text/html";
    //"text/plain"
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->AddAttachment($attach, $nameToSend);
    foreach ($tos as $name => $address) {
        $mail->AddAddress("{$address}", "{$name}");
    }
    if (!$mail->send()) {
        $GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo);
        return false;
    } else {
        return true;
    }
}
开发者ID:omusico,项目名称:sugar_work,代码行数:88,代码来源:send_mail.php

示例3: sendSugarPHPMail

/**
 * A wrapper for sugar's mail class
 * Sends emails to everyon in $tos array.
 * $tos['user name'] = 'username@domain.com';
 *
 * @example :   $tos['Some User'] = 'SomeUser@somewhere.com';
 *              $tos['Some User 2'] = 'SomeUser2@somewhere.com';
 *              sendSugarPHPMail($tos, 'hi', 'hello fellas');
 *
 * @param associative array
 * @param string $subject
 * @param string $body
 * @return boolean
 */
function sendSugarPHPMail($tos, $subject, $body, $type = "text/html")
{
    require_once 'include/SugarPHPMailer.php';
    require_once 'modules/Administration/Administration.php';
    $mail = new SugarPHPMailer();
    $admin = new Administration();
    $admin->retrieveSettings();
    if ($admin->settings['mail_sendtype'] == "SMTP") {
        $mail->Host = $admin->settings['mail_smtpserver'];
        $mail->Port = $admin->settings['mail_smtpport'];
        if ($admin->settings['mail_smtpauth_req']) {
            $mail->SMTPAuth = TRUE;
            $mail->Username = $admin->settings['mail_smtpuser'];
            $mail->Password = $admin->settings['mail_smtppass'];
        }
        $mail->Mailer = "smtp";
        $mail->SMTPKeepAlive = true;
    } else {
        $mail->mailer = 'sendmail';
    }
    $mail->From = $admin->settings['notify_fromaddress'];
    $mail->FromName = $admin->settings['notify_fromname'];
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->ContentType = $type;
    //"text/plain" # Envia en texto plano
    foreach ($tos as $name => $address) {
        $mail->AddAddress("{$address}", "{$name}");
    }
    if (!$mail->send()) {
        $mensaje_de_error = "sendSugarPHPMail - error: '{$mail->ErrorInfo}'";
        $GLOBALS['log']->info($mensaje_de_error);
        throw new Exception($mensaje_de_error);
    } else {
        return true;
    }
}
开发者ID:dinhquyet92,项目名称:sugarcrm_advanced_workflows,代码行数:51,代码来源:gcoop_global_funcs.php


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