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


PHP Zend_Mail::addTo方法代码示例

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


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

示例1: 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

示例2: forgotPassword

 /**
  * @param string $name
  * @return string
  * @throws \Zend_Mail_Exception
  */
 public function forgotPassword($name)
 {
     $kga = $this->getKga();
     $database = $this->getDatabase();
     $is_customer = $database->is_customer_name($name);
     $mail = new Zend_Mail('utf-8');
     $mail->setFrom($kga['conf']['adminmail'], 'Kimai - Open Source Time Tracking');
     $mail->setSubject($kga['lang']['passwordReset']['mailSubject']);
     $transport = new Zend_Mail_Transport_Sendmail();
     $passwordResetHash = str_shuffle(MD5(microtime()));
     if ($is_customer) {
         $customerId = $database->customer_nameToID($name);
         $customer = $database->customer_get_data($customerId);
         $database->customer_edit($customerId, array('passwordResetHash' => $passwordResetHash));
         $mail->addTo($customer['mail']);
     } else {
         $userId = $database->user_name2id($name);
         $user = $database->user_get_data($userId);
         $database->user_edit($userId, array('passwordResetHash' => $passwordResetHash));
         $mail->addTo($user['mail']);
     }
     Kimai_Logger::logfile('password reset: ' . $name . ($is_customer ? ' as customer' : ' as user'));
     $ssl = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
     $url = ($ssl ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/forgotPassword.php?name=' . urlencode($name) . '&key=' . $passwordResetHash;
     $message = $kga['lang']['passwordReset']['mailMessage'];
     $message = str_replace('%{URL}', $url, $message);
     $mail->setBodyText($message);
     try {
         $mail->send($transport);
         return $kga['lang']['passwordReset']['mailConfirmation'];
     } catch (Zend_Mail_Transport_Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:kimai,项目名称:kimai,代码行数:39,代码来源:Kimai.php

示例3: sendMessage

 /**
  * @param string $subject
  *  The subject. May contain variable references to memebrs
  *  of the $fields array.
  * @param string $view
  *  The name of a view
  * @param array $fields
  *  The fields referenced in the subject and/or view
  * @param array $optoins
  *  Array of options. Can include:
  *  "html" => Defaults to false. Whether to send as HTML email.
  *  "name" => A human-readable name in addition to the address.
  *  "from" => An array of email_address => human_readable_name
  */
 function sendMessage($subject, $view, $fields = array(), $options = array())
 {
     if (!isset($options['from'])) {
         $url_parts = parse_url(Pie_Request::baseUrl());
         $domain = $url_parts['host'];
         $options['from'] = array("email_bot@" . $domain => $domain);
     } else {
         if (!is_array($options['from'])) {
             throw new Pie_Exception_WrongType(array('field' => '$options["from"]', 'type' => 'array'));
         }
     }
     // Set up the default mail transport
     $tr = new Zend_Mail_Transport_Sendmail('-f' . $this->address);
     Zend_Mail::setDefaultTransport($tr);
     $mail = new Zend_Mail();
     $from_name = reset($options['from']);
     $mail->setFrom(key($options['from']), $from_name);
     if (isset($options['name'])) {
         $mail->addTo($this->address, $options['name']);
     } else {
         $mail->addTo($this->address);
     }
     $subject = Pie::expandString($subject, $fields);
     $body = Pie::view($view, $fields);
     $mail->setSubject($subject);
     if (empty($options['html'])) {
         $mail->setBodyText($body);
     } else {
         $mail->setBodyHtml($body);
     }
     $mail->send();
     return true;
 }
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:47,代码来源:Email.php

示例4: _sendNewCommentEmail

 /**
  * Send email notification to moderators when a new comment is posted
  * 
  * @todo move logic to model / library class
  * 
  * @param HumanHelp_Model_Comment $comment
  * @param HumanHelp_Model_Page $page
  */
 public function _sendNewCommentEmail(HumanHelp_Model_Comment $comment, HumanHelp_Model_Page $page)
 {
     $config = Zend_Registry::get('config');
     $emailTemplate = new Zend_View();
     $emailTemplate->setScriptPath(APPLICATION_PATH . '/views/emails');
     $emailTemplate->addHelperPath(APPLICATION_PATH . '/views/helpers', 'HumanHelp_View_Helper_');
     $emailTemplate->setEncoding('UTF-8');
     $emailTemplate->comment = $comment;
     $emailTemplate->page = $page;
     $emailTemplate->baseUrl = 'http://' . $_SERVER['HTTP_HOST'] . $this->view->baseUrl;
     $bodyHtml = $emailTemplate->render('newComment.phtml');
     $bodyText = $emailTemplate->render('newComment.ptxt');
     $mail = new Zend_Mail();
     $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE)->setBodyHtml($bodyHtml, 'UTF-8')->setBodyText($bodyText, 'UTF-8')->setSubject("New comment on '{$page->getTitle()}' in '{$page->getBook()->getTitle()}'")->setFrom($config->fromAddress, $config->fromName);
     if (is_object($config->notifyComments)) {
         foreach ($config->notifyComments->toArray() as $rcpt) {
             $mail->addTo($rcpt);
         }
     } else {
         $mail->addTo($config->notifyComments);
     }
     if ($config->smtpServer) {
         $transport = new Zend_Mail_Transport_Smtp($config->smtpServer, $config->smtpOptions->toArray());
     } else {
         $transport = new Zend_Mail_Transport_Sendmail();
     }
     $mail->send($transport);
 }
开发者ID:shevron,项目名称:HumanHelp,代码行数:36,代码来源:IndexController.php

示例5: sendEmail

 /**
  * Send an email
  *
  * @param  mixed $emails String or array or emails
  * @param  string $subject 
  * @param  string $message 
  * @return boolean
  */
 public static function sendEmail($emails, $subject, $message, $fromName, $fromEmail)
 {
     $mail = new Zend_Mail();
     if (is_array($emails)) {
         foreach ($emails as $email) {
             $mail->addTo($email);
         }
     } else {
         $mail->addTo($emails);
     }
     $mail->setSubject($subject);
     $mail->setBodyHtml($message);
     $mail->setFrom($fromEmail, $fromName);
     $sent = true;
     try {
         $mail->send();
     } catch (Exception $e) {
         $sent = false;
         $error = $e->getMessage();
         //            Logger::LogEmail($e->getMessage(), Zend_Log::ERR);
         //            Logger::LogEmail('Email: ' . $email, Zend_Log::INFO);
         //            Logger::LogEmail('Subject: ' . $subject, Zend_Log::INFO);
         //            Logger::LogEmail('Message: ' . $message, Zend_Log::INFO);
     }
     return [Sent => $sent, Message => $error];
 }
开发者ID:Ewaldaz,项目名称:Be-your-light,代码行数:34,代码来源:Mailer.php

示例6: send

 /**
  * Odesle E-mail
  *
  * @param string $recipient E-mail prijemce
  */
 public function send($recipient)
 {
     $smtpOptions = array('auth' => 'login', 'username' => 'mybase.unodor@gmail.com', 'password' => 'opticau51', 'ssl' => 'ssl', 'port' => 465);
     $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $smtpOptions);
     $this->_mail->setBodyHtml($this->_bodyText);
     $this->_mail->addTo($recipient);
     $this->_mail->send($mailTransport);
 }
开发者ID:besters,项目名称:My-Base,代码行数:13,代码来源:Mail.php

示例7: notifyCustomerOfDelivery

 /**
  * Notifies the customer of their delivery.
  *
  * @param \IocExample\Model\Customer $customer
  * @param \IocExample\Model\Order $order
  * @return void
  */
 public function notifyCustomerOfDelivery(Customer $customer, Order $order)
 {
     $this->_mailer->setFrom('orders@chrisweldon.net', 'Grumpy Baby Orders');
     $this->_mailer->setSubject('Order #' . $order->getId() . ' out for Delivery');
     $this->_mailer->setBodyText('Your order is being shipped!');
     $this->_mailer->addTo($customer->getEmail(), $customer->getName());
     $this->_mailer->send();
 }
开发者ID:neraath,项目名称:ioc-php-talk,代码行数:15,代码来源:EmailNotifier.php

示例8: postInsert

	/**
	 * Generate token and update user record.
	 * @see Doctrine_Record_Listener::postInsert()
	 */
	public function postInsert(Doctrine_Event $event) {
		$this->_user = $event->getInvoker();

		$this->assignViewVariables();

		$this->_mail->setBodyHtml($this->renderView('html'));
		$this->_mail->setBodyText($this->renderView('plain'));
		$this->_mail->setSubject($this->_subject);
		$this->_mail->addTo($this->_user->email, $this->_nickname);

		$this->_mail->send();
	}
开发者ID:niieani,项目名称:nandu,代码行数:16,代码来源:Email.php

示例9: send

 public function send($template, array $values = array())
 {
     // create a new mail
     $mail = new Zend_Mail('UTF-8');
     if (isset($values['to'])) {
         if (is_array($values['to'])) {
             foreach ($values['to'] as $address) {
                 $mail->addTo($address);
             }
         } else {
             $mail->addTo($values['to']);
         }
         unset($values['to']);
     } else {
         throw new Exception('to not send in $values');
     }
     // set cc
     if (isset($values['cc'])) {
         if (is_array($values['cc'])) {
             foreach ($values['cc'] as $address) {
                 $mail->addCc($address);
             }
         } else {
             $mail->addCc($values['cc']);
         }
         unset($values['cc']);
     }
     // set bcc
     if (isset($values['bcc'])) {
         if (is_array($values['bcc'])) {
             foreach ($values['bcc'] as $address) {
                 $mail->addBcc($address);
             }
         } else {
             $mail->addBcc($values['bcc']);
         }
         unset($values['bcc']);
     }
     // get the template
     $templateModel = new Core_Model_Templates();
     $data = $templateModel->show($template, $values);
     // set subject and body
     $mail->setSubject($data['subject']);
     $mail->setBodyText($data['body']);
     if (empty(Daiquiri_Config::getInstance()->mail->debug)) {
         $mail->send();
     } else {
         Zend_Debug::dump($mail->getRecipients());
         Zend_Debug::dump($mail->getSubject());
         Zend_Debug::dump($mail->getBodyText());
     }
 }
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:52,代码来源:Mail.php

示例10: __construct

 /**
  *
  * @param Zend_Controller_Request_Abstract$request
  * @param Zend_Mail|null $mailer
  * @param string|null $to
  */
 public function __construct($request, $config, $mailer = NULL)
 {
     $this->_request = $request;
     if (isset($mailer)) {
         $this->_mailer = $mailer;
     } else {
         $this->_mailer = new Zend_Mail('UTF-8');
     }
     $this->_mailer->addTo($config->contactEmail);
     if (!empty($config->fromEmail)) {
         $this->_mailer->setFrom($config->fromEmail);
     }
 }
开发者ID:jbazant,项目名称:mtgim,代码行数:19,代码来源:Contact.php

示例11: send

 /**
  * load the template and send the message
  *
  * @param string $recipient
  * @param array $from
  * @param string $subject
  * @param string $template
  * @param array $data
  * @param string $cc
  * @return bool
  */
 public function send($recipient, $from = array(), $subject, $message, $cc = false)
 {
     $config = Zend_Registry::get('config');
     $this->_view->addScriptPath($config->filepath->emailTemplates);
     $this->_view->emailBody = $message;
     $this->_mail->setBodyHtml($this->_view->render('template.phtml'));
     $this->_mail->setFrom($from[0], $from[1]);
     $this->_mail->addTo($recipient);
     if ($cc) {
         $this->_mail->addCc($cc);
     }
     $this->_mail->setSubject($subject);
     return $this->_mail->send($this->_transport);
 }
开发者ID:laiello,项目名称:digitalus-cms,代码行数:25,代码来源:Mail.php

示例12: sendMail

 /**
  * Send a mail based on the configuration in the emails table
  *
  * @throws EngineBlock_Exception in case there is no EmailConfiguration in emails table
  * @param $emailAddress the email address of the recipient
  * @param $emailType the pointer to the emails configuration
  * @param $replacements array where the key is a variable (e.g. {user}) and the value the string where the variable should be replaced
  * @return void
  */
 public function sendMail($emailAddress, $emailType, $replacements)
 {
     $dbh = $this->_getDatabaseConnection();
     $query = "SELECT email_text, email_from, email_subject, is_html FROM emails where email_type = ?";
     $parameters = array($emailType);
     $statement = $dbh->prepare($query);
     $statement->execute($parameters);
     $rows = $statement->fetchAll();
     if (count($rows) !== 1) {
         EngineBlock_ApplicationSingleton::getLog()->err("Unable to send mail because of missing email configuration: " . $emailType);
         return;
     }
     $emailText = $rows[0]['email_text'];
     foreach ($replacements as $key => $value) {
         // Single value replacement
         if (!is_array($value)) {
             $emailText = str_ireplace($key, $value, $emailText);
         } else {
             $replacement = '<ul>';
             foreach ($value as $valElem) {
                 $replacement .= '<li>' . $valElem . '</li>';
             }
             $replacement .= '</ul>';
             $emailText = str_ireplace($key, $replacement, $emailText);
         }
     }
     $emailFrom = $rows[0]['email_from'];
     $emailSubject = $rows[0]['email_subject'];
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($emailText, 'utf-8', 'utf-8');
     $mail->setFrom($emailFrom, "SURFconext Support");
     $mail->addTo($emailAddress);
     $mail->setSubject($emailSubject);
     $mail->send();
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:44,代码来源:Mailer.php

示例13: 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

示例14: contatoAction

 public function contatoAction()
 {
     if ($this->_request->isPost()) {
         $html = new Zend_View();
         $html->setScriptPath(APPLICATION_PATH . '/modules/default/layouts/scripts/');
         $title = 'Contato | Instag';
         $to = 'eduardo@inndeia.com';
         $cc = 'renato@inndeia.com';
         $html->assign('title', $title);
         $html->assign('nome', $this->_request->getPost('nome'));
         $html->assign('email', $this->_request->getPost('email'));
         $html->assign('assunto', $this->_request->getPost('assunto'));
         $html->assign('mensagem', $this->_request->getPost('mensagem'));
         $mail = new Zend_Mail('utf-8');
         $bodyText = $html->render('contato.phtml');
         $config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => 'nao-responder@instag.com.br', 'password' => 'Inndeia123');
         $transport = new Zend_Mail_Transport_Smtp('127.0.0.1', $config);
         $mail->addTo($to);
         $mail->addCc($cc);
         $mail->setSubject($title);
         $mail->setFrom($this->_request->getPost('email'), $this->_request->getPost('name'));
         $mail->setBodyHtml($bodyText);
         $send = $mail->send($transport);
         if ($send) {
             $this->_helper->flashMessenger->addMessage('Sua mensagem foi enviada com sucesso, em breve entraremos em contato.');
         } else {
             $this->_helper->flashMessenger->addMessage('Falha no envio, tente novamente!');
         }
         $this->_redirect('/index');
     }
 }
开发者ID:pccnf,项目名称:proj_instag,代码行数:31,代码来源:IndexController.php

示例15: runTest

 public function runTest($params = array())
 {
     $config = $this->_getConfig($params);
     $sock = false;
     try {
         $sock = fsockopen($config['host'], $config['port'], $errno, $errstr, 20);
     } catch (Exception $e) {
     }
     if ($sock) {
         Mage::helper('amsmtp')->debug('Connection test successful: connected to ' . $config['host'] . ':' . $config['port']);
         if ($config['test_email']) {
             $from = Mage::getStoreConfig('trans_email/ident_general/email');
             Mage::helper('amsmtp')->debug('Preparing to send test e-mail to ' . $config['test_email'] . ' from ' . $from);
             $mail = new Zend_Mail();
             $mail->addTo($config['test_email'])->setSubject(Mage::helper('amsmtp')->__('Amasty SMTP Email Test Message'))->setBodyText(Mage::helper('amsmtp')->__('If you see this e-mail, your configuration is OK.'))->setFrom($from);
             try {
                 $mail->send($this->getTransport($params));
                 Mage::helper('amsmtp')->debug('Test e-mail was sent successfully!');
             } catch (Exception $e) {
                 Mage::helper('amsmtp')->debug('Test e-mail failed: ' . $e->getMessage());
                 return false;
             }
         }
         return true;
     }
     Mage::helper('amsmtp')->debug('Connection test failed: connection to ' . $config['host'] . ':' . $config['port'] . ' failed. Error: ' . $errstr . ' (' . $errno . ')');
     return false;
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:28,代码来源:Transport.php


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