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


PHP Zend_Mail::setDefaultTransport方法代码示例

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


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

示例1: getMail

 /**
  * @return Zend_Mail
  * @throws Zend_Mail_Protocol_Exception
  */
 public static function getMail(Users_Model_User $user, $subject)
 {
     $file = CommunityID_Resources::getResourcePath('reminder_mail.txt');
     $emailTemplate = file_get_contents($file);
     $emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
     $currentUrl = Zend_OpenId::selfURL();
     preg_match('#(.*)/manageusers/sendreminder#', $currentUrl, $matches);
     $emailTemplate = str_replace('{registrationURL}', $matches[1] . '/register/eula?token=' . $user->token, $emailTemplate);
     // can't use $this->_config 'cause it's a static function
     $configEmail = Zend_Registry::get('config')->email;
     switch (strtolower($configEmail->transport)) {
         case 'smtp':
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($configEmail->host, $configEmail->toArray()));
             break;
         case 'mock':
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
             break;
         default:
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
     }
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyText($emailTemplate);
     $mail->setFrom($configEmail->supportemail);
     $mail->addTo($user->email);
     $mail->setSubject($subject);
     return $mail;
 }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:31,代码来源:ManageusersController.php

示例2: useAccount

 /**
  * Will set the Default Transport object for the mail object based on the supplied accountname
  *
  * @param string $accountName
  * @return boolean TRUE/FALSE
  */
 public function useAccount($accountName)
 {
     //If a mail object exists, overwrite with new object
     if ($this->_mail) {
         $this->_constructMail();
     }
     $this->m_UseAccount = $accountName;
     $account = $this->m_Accounts->get($accountName);
     if ($account->m_IsSMTP == "Y") {
         require_once 'Zend/Mail/Transport/Smtp.php';
         if ($account->m_SMTPAuth == "Y") {
             $config = array('auth' => 'login', 'username' => $account->m_Username, 'password' => $account->m_Password, "port" => $account->m_Port, 'ssl' => $account->m_SSL);
         } else {
             $config = array();
         }
         $mailTransport = new Zend_Mail_Transport_Smtp($account->m_Host, $config);
         $this->_mail->setDefaultTransport($mailTransport);
     } else {
         require_once 'Zend/Mail/Transport/Sendmail.php';
         $mailTransport = new Zend_Mail_Transport_Sendmail();
         $this->_mail->setDefaultTransport($mailTransport);
     }
     $this->_mail->setFrom($account->m_FromEmail, $account->m_FromName);
     return $this;
 }
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:31,代码来源:emailService.php

示例3: sendMail

 public static function sendMail($content)
 {
     $front = Zend_Controller_Front::getInstance();
     $email = new Base_Php_Overloader($front->getParam("bootstrap")->getOption('smtp'));
     $smtp = $email->domain;
     $username = $email->username;
     $password = $email->password;
     $port = $email->port;
     $config = new Zend_Mail_Transport_Smtp($smtp, array('auth' => 'login', 'username' => $username, 'password' => $password, 'ssl' => "ssl", 'port' => $port));
     Zend_Mail::setDefaultTransport($config);
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($content['body']);
     // Email body
     $mail->setFrom($content['sender'], $content['nameSender']);
     // Sender (Email, Name)
     $mail->addTo(isset($content['recipient']) ? $content['recipient'] : '', isset($content['nameRecipient']) ? $content['nameRecipient'] : '');
     // Recipient (Email, Name)
     $mail->addCc($content['sender'], $content['nameSender']);
     // CC to // Reply to Sender
     $mail->setSubject($content['subject']);
     // Subject Email
     try {
         $flag = $mail->send($config);
     } catch (Zend_Exception $e) {
         Base_Helper_Log::getInstance()->log(PHP_EOL . date('H:i:s :::: ') . ' [MAIL] ' . $e->getMessage());
         $flag = false;
     }
     if ($flag) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:HuyTran0424,项目名称:noeavrsev345452dfgdfgsg,代码行数:33,代码来源:Mail.php

示例4: sendMail

 public function sendMail()
 {
     if (func_num_args() >= 4) {
         $to = func_get_arg(0);
         $from = func_get_arg(1);
         $subject = func_get_arg(2);
         $messageRecieved = func_get_arg(3);
         $tr = new Zend_Mail_Transport_Smtp($this->_host, array('auth' => 'login', 'username' => $this->_username, 'password' => $this->_password, 'port' => $this->_port));
         Zend_Mail::setDefaultTransport($tr);
         $mail = new Zend_Mail('utf-8');
         $mail->setFrom($from);
         $mail->setBodyHtml($messageRecieved);
         $mail->addTo($to);
         $mail->setSubject($subject);
         $mail->addHeader('MIME-Version', '1.0');
         $mail->addHeader('Content-Transfer-Encoding', '8bit');
         $mail->addHeader('X-Mailer:', 'PHP/' . phpversion());
         try {
             $mail->send();
             $response = "Mail sent";
             return $response;
         } catch (Exception $e) {
             throw new Zend_Controller_Action_Exception('SendGrid Mail sending error', 500);
         }
     } else {
         throw new Zend_Controller_Action_Exception('Paramter Not passed', 500);
     }
 }
开发者ID:sumitglobussoft,项目名称:food-delivery-,代码行数:28,代码来源:Mailer.php

示例5: indexAction

 public function indexAction()
 {
     $form = new Application_Form_FaleConoscoForm();
     $this->view->form = $form;
     $params = $this->_request->getParams();
     if ($this->_request->isPost() && $form->isValid($params)) {
         try {
             $vista = Services::get('vista_rest');
             $vista->getAuthEmail();
             $smtpData = $vista->getResult();
             $config = array('auth' => 'login', 'username' => $smtpData['user'], 'password' => $smtpData['pass'], 'port' => $smtpData['port']);
             $transport = new Zend_Mail_Transport_Smtp($smtpData['smtp'], $config);
             Zend_Mail::setDefaultTransport($transport);
             $html = new Zend_View();
             $html->setScriptPath(APPLICATION_PATH . '/views/scripts/fale-conosco/');
             $html->data = $params;
             $emailBody = $html->render('email-body.phtml');
             $mail = new Zend_Mail();
             $mail->setBodyHtml($emailBody);
             $mail->setFrom('atendimento@esselence.com.br', $params['nome']);
             $mail->addTo('atendimento@esselence.com.br', 'Esselence');
             $mail->setSubject("Contato pelo Site {$params['nome']}");
             $mail->send();
             $this->view->success = true;
         } catch (Exception $e) {
             print_r($e->getMessage());
             exit;
         }
     }
 }
开发者ID:elvisdandrea,项目名称:esselence,代码行数:30,代码来源:FaleConoscoController.php

示例6: indexAction

 public function indexAction()
 {
     do {
         $message = App_Model_Queue::pop(App_Model_Queue::EMAIL);
         if ($message) {
             $user = App_Model_User::fetchOne(['id' => (string) $message->user]);
             $config = $user->data['mail'];
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($config['server'], ['auth' => $config['auth'], 'username' => $config['username'], 'password' => $config['password'], 'port' => $config['port'], 'ssl' => $config['ssl']]));
             $mail = new Zend_Mail('UTF-8');
             foreach ($message->receivers as $receiver) {
                 $mail->addTo($receiver['email'], $receiver['name']);
             }
             $this->writeLine("------------------------------------------------");
             $this->writeLine("to: " . print_r($message->receivers, true));
             $this->writeLine("from: " . implode(', ', [$user->data['mail']['username'], $user->data['mail']['name']]));
             $this->writeLine("Subject: " . $message->subject);
             $mail->setSubject($message->subject);
             $mail->setBodyHtml($message->content);
             $mail->setFrom($user->data['mail']['username'], $user->data['mail']['name']);
             $this->writeLine("Start sending...");
             try {
                 $mail->send();
             } catch (Exception $e) {
                 $this->writeLine($e->getMessage());
             }
             $this->writeLine('>>>> Done');
             sleep(1);
         }
     } while (true);
 }
开发者ID:execrot,项目名称:sender-server,代码行数:30,代码来源:MailController.php

示例7: sendEmail

 public function sendEmail($template, $to, $subject, $params = array())
 {
     try {
         $config = array('auth' => 'Login', 'port' => $this->_bootstrap_options['mail']['port'], 'ssl' => 'ssl', 'username' => $this->_bootstrap_options['mail']['username'], 'password' => $this->_bootstrap_options['mail']['password']);
         $tr = new Zend_Mail_Transport_Smtp($this->_bootstrap_options['mail']['server'], $config);
         Zend_Mail::setDefaultTransport($tr);
         $mail = new Zend_Mail('UTF-8');
         $layout = new Zend_Layout();
         $layout->setLayoutPath($this->_bootstrap_options['mail']['layout']);
         $layout->setLayout('email');
         $view = $layout->getView();
         $view->domain_url = $this->_bootstrap_options['site']['domainurl'];
         $view = new Zend_View();
         $view->params = $params;
         $view->setScriptPath($this->_bootstrap_options['mail']['view_script']);
         $layout->content = $view->render($template . '.phtml');
         $content = $layout->render();
         $mail->setBodyText(preg_replace('/<[^>]+>/', '', $content));
         $mail->setBodyHtml($content);
         $mail->setFrom($this->_bootstrap_options['mail']['from'], $this->_bootstrap_options['mail']['from_name']);
         $mail->addTo($to);
         $mail->setSubject($subject);
         $mail->send();
     } catch (Exception $e) {
         // 这里要完善
     }
     return true;
 }
开发者ID:ud223,项目名称:yj,代码行数:28,代码来源:Email.php

示例8: __construct

 public function __construct()
 {
     $this->_transport = new Zend_Mail_Transport_Smtp($this->_smtp_server, $this->_config);
     Zend_Mail::setDefaultTransport($this->_transport);
     //$this->_mail = new Zend_Mail('UTF-8');
     $this->_mail = new TS_Mail_Model();
 }
开发者ID:hYOUstone,项目名称:tsg,代码行数:7,代码来源:Mail.php

示例9: getMail

    /**
     *
     * @return Zend_Mail_Transport_Abstract|null
     */
    public function getMail()
    {
        if (null === $this->_transport) {
            $options = $this->getOptions();
            foreach($options as $key => $option) {
                $options[strtolower($key)] = $option;
            }
            $this->setOptions($options);

            if(isset($options['transport']) &&
               !is_numeric($options['transport']))
            {
                $this->_transport = $this->_setupTransport($options['transport']);
                if(!isset($options['transport']['register']) ||
                   $options['transport']['register'] == '1' ||
                   (isset($options['transport']['register']) &&
                        !is_numeric($options['transport']['register']) &&
                        (bool) $options['transport']['register'] == true))
                {
                    Zend_Mail::setDefaultTransport($this->_transport);
                }
            }

            $this->_setDefaults('from');
            $this->_setDefaults('replyTo');
        }

        return $this->_transport;
    }
开发者ID:realfluid,项目名称:umbaugh,代码行数:33,代码来源:Mail.php

示例10: getMail

    /**
     * @return Zend_Mail
     * @throws Zend_Mail_Protocol_Exception
     */
    public static function getMail($name, $email, $feedback)
    {
        // can't use $this-_config 'cause it's a static function
        $configEmail = Zend_Registry::get('config')->email;
        switch (strtolower($configEmail->transport)) {
            case 'smtp':
                Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($configEmail->host, $configEmail->toArray()));
                break;
            case 'mock':
                Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
                break;
            default:
                Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
        }
        $mail = new Zend_Mail('UTF-8');
        $mail->setBodyText(<<<EOD
Dear Administrator,

The community-id feedback form has just been used to send you the following:

Name: {$name}
E-mail: {$email}
Feedback:
{$feedback}
EOD
);
        $mail->setFrom($configEmail->supportemail);
        $mail->addTo($configEmail->supportemail);
        $mail->setSubject('Community-ID feedback form');
        return $mail;
    }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:35,代码来源:FeedbackController.php

示例11: _initEmail

 protected function _initEmail()
 {
     $email_config = array('auth' => 'plain', 'username' => 'navchalna1@gmail.com', 'password' => 'vikucia1994', 'ssl' => 'ssl');
     //створюємо транспорт
     $transport = new Zend_Mail_Transport_Smtp('navchalna1@gmail.com', $email_config);
     Zend_Mail::setDefaultTransport($transport);
 }
开发者ID:Vika1994,项目名称:comments,代码行数:7,代码来源:Bootstrap.php

示例12: tiki_mail_setup

function tiki_mail_setup()
{
    static $done = false;
    if ($done) {
        return;
    }
    global $prefs;
    if ($prefs['zend_mail_handler'] == 'smtp') {
        $options = array();
        if ($prefs['zend_mail_smtp_auth']) {
            $options['auth'] = $prefs['zend_mail_smtp_auth'];
            $options['username'] = $prefs['zend_mail_smtp_user'];
            $options['password'] = $prefs['zend_mail_smtp_pass'];
        }
        if ($prefs['zend_mail_smtp_port']) {
            $options['port'] = $prefs['zend_mail_smtp_port'];
        }
        if ($prefs['zend_mail_smtp_security']) {
            $options['ssl'] = $prefs['zend_mail_smtp_security'];
        }
        $transport = new Zend_Mail_Transport_Smtp($prefs['zend_mail_smtp_server'], $options);
        Zend_Mail::setDefaultTransport($transport);
    }
    $done = true;
}
开发者ID:railfuture,项目名称:tiki-website,代码行数:25,代码来源:maillib.php

示例13: sendEmail

 /**
  * Send email
  *
  * TODO: add language specific template based on recepient default language
  */
 public static function sendEmail($to, $subject, $body, $show_errors = false)
 {
     if (Zend_Registry::get('config')->get('mail_adapter') == 'smtp') {
         $smtp_config = array('ssl' => Zend_Registry::get('config')->get('mail_security'), 'port' => Zend_Registry::get('config')->get('mail_port'), 'auth' => Zend_Registry::get('config')->get('mail_login'), 'username' => Zend_Registry::get('config')->get('mail_username'), 'password' => Zend_Registry::get('config')->get('mail_password'));
         $tr = new Zend_Mail_Transport_Smtp(Zend_Registry::get('config')->get('mail_host'), $smtp_config);
     } else {
         $tr = new Zend_Mail_Transport_Sendmail();
     }
     Zend_Mail::setDefaultTransport($tr);
     $mail = new Zend_Mail('utf8');
     $mail->setBodyHtml($body);
     $mail->setFrom(Zend_Registry::get('config')->get('mail_from'), Zend_Registry::get('config')->get('mail_from_name'));
     $mail->addTo($to);
     $mail->setSubject($subject);
     try {
         $mail->send($tr);
     } catch (Zend_Mail_Exception $e) {
         if (method_exists($tr, 'getConnection') && method_exists($tr->getConnection(), 'getLog')) {
             Application_Plugin_Common::log(array($e->getMessage(), $tr->getConnection()->getLog()));
         } else {
             Application_Plugin_Common::log(array($e->getMessage(), 'error sending mail'));
         }
         if ($show_errors) {
             Application_Plugin_Alerts::error(Zend_Registry::get('Zend_Translate')->translate('Something went wrong, email was not sent.'), 'off');
         }
         return false;
     }
     return true;
 }
开发者ID:georgepaul,项目名称:songslikesocial,代码行数:34,代码来源:Common.php

示例14: send

 /**
  * sends a standard email
  * 
  * @param string $subject
  * @param string $toName
  * @param array $toEmails
  * @param array $emailOptions
  * @param string $fromName
  * @param string $fromEmail
  */
 public function send($subject, $toName, $toEmails = array(), $emailOptions = array(), $fromName = null, $fromEmail = null)
 {
     $logger = Zend_Registry::get('logger');
     $config = vkNgine_Config::getSystemConfig()->mail;
     if ($config->serverType == 'smtp') {
         $tr = new Zend_Mail_Transport_Smtp($config->server, $config->toArray());
     }
     Zend_Mail::setDefaultTransport($tr);
     foreach ($toEmails as $email) {
         $mail = new Zend_Mail();
         if ($emailOptions['type'] == 'html') {
             $mail->setBodyHtml($emailOptions['email']);
         } else {
             $mail->setBodyText($emailOptions['email']);
         }
         if (!$fromName || !$fromEmail) {
             $mail->setFrom($config->noreply, 'GYM Tracker');
         } else {
             $mail->setFrom($fromEmail, $fromName);
         }
         $mail->addTo($email, $toName);
         $mail->setSubject($subject);
         try {
             $mail->send();
         } catch (Zend_Mail_Protocol_Exception $e) {
             $logger->log('MESSAGE_SEND_FAILED', 'Unable to send to ' . $email . ' - ' . $e->getMessage(), 1);
         }
     }
 }
开发者ID:AlexanderMazaletskiy,项目名称:gym-Tracker-App,代码行数:39,代码来源:Email.php

示例15: saveFiles

 public function saveFiles($fileArray)
 {
     if (empty($fileArray)) {
         return array();
     }
     // Init connection
     $this->initConnection();
     $savedFiles = array();
     @ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
     @ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
     $charset = "utf-8";
     #$charset = "iso-8859-1";
     $mail = new Zend_Mail($charset);
     $setReturnPath = Mage::getStoreConfig('system/smtp/set_return_path');
     switch ($setReturnPath) {
         case 1:
             $returnPathEmail = $this->getDestination()->getEmailSender();
             break;
         case 2:
             $returnPathEmail = Mage::getStoreConfig('system/smtp/return_path_email');
             break;
         default:
             $returnPathEmail = null;
             break;
     }
     if ($returnPathEmail !== null) {
         $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $returnPathEmail);
         Zend_Mail::setDefaultTransport($mailTransport);
     }
     $mail->setFrom($this->getDestination()->getEmailSender(), $this->getDestination()->getEmailSender());
     foreach (explode(",", $this->getDestination()->getEmailRecipient()) as $email) {
         if ($charset === "utf-8") {
             $mail->addTo($email, '=?utf-8?B?' . base64_encode($email) . '?=');
         } else {
             $mail->addTo($email, $email);
         }
     }
     foreach ($fileArray as $filename => $data) {
         if ($this->getDestination()->getEmailAttachFiles()) {
             $attachment = $mail->createAttachment($data);
             $attachment->filename = $filename;
         }
         $savedFiles[] = $filename;
     }
     #$mail->setSubject($this->_replaceVariables($this->getDestination()->getEmailSubject(), $firstFileContent));
     if ($charset === "utf-8") {
         $mail->setSubject('=?utf-8?B?' . base64_encode($this->_replaceVariables($this->getDestination()->getEmailSubject(), implode("\n\n", $fileArray))) . '?=');
     } else {
         $mail->setSubject($this->_replaceVariables($this->getDestination()->getEmailSubject(), implode("\n\n", $fileArray)));
     }
     $mail->setBodyText(strip_tags($this->_replaceVariables($this->getDestination()->getEmailBody(), implode("\n\n", $fileArray))));
     $mail->setBodyHtml($this->_replaceVariables($this->getDestination()->getEmailBody(), implode("\n\n", $fileArray)));
     try {
         $mail->send(Mage::helper('xtcore/utils')->getEmailTransport());
     } catch (Exception $e) {
         $this->getTestResult()->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('Error while sending email: %s', $e->getMessage()));
         return false;
     }
     return $savedFiles;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:60,代码来源:Email.php


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