setBodyText() публичный Метод

Sets the text body for the message.
public setBodyText ( string $txt, string $charset = null, string $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE ) : Zend_Mail
$txt string
$charset string
$encoding string
Результат Zend_Mail Provides fluent interface
Пример #1
0
 /**
  * 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('*****@*****.**', '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();
 }
Пример #2
0
	/**
	 * 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();
	}
Пример #3
0
 public function recoverAction()
 {
     $request = $this->getRequest();
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $config = $registry->get('config');
     if ($auth->hasIdentity()) {
         $registry->set("pleaseSignout", true);
         return $this->_forward("index", "logout");
     }
     $people = Ml_Model_People::getInstance();
     $recover = Ml_Model_Recover::getInstance();
     $form = $recover->form();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $find = $form->getValues();
         //AccountRecover.php validator pass this data: not very hortodox
         $getUser = $registry->accountRecover;
         $securityCode = $recover->newCase($getUser['id']);
         $this->view->securitycode = $securityCode;
         $this->view->recoverUser = $getUser;
         $this->view->recovering = true;
         $mail = new Zend_Mail();
         $mail->setBodyText($this->view->render("password/emailRecover.phtml"))->setFrom($config['robotEmail']['addr'], $config['robotEmail']['name'])->addTo($getUser['email'], $getUser['name'])->setSubject('Recover your ' . $config['applicationname'] . ' account')->send();
     }
     $this->view->recoverForm = $form;
 }
Пример #4
0
 public function sendStatusEmail()
 {
     $vBody = '';
     $aSuccess = $this->getSuccess();
     if (count($aSuccess) > 0) {
         $vBody .= "The following completed successfully:\n * " . implode("\n * ", $aSuccess) . "\n\n";
     }
     $aErrors = $this->getErrors();
     if (count($aErrors) > 0) {
         $vBody .= "The following errors occurred (feed - sku - error):\n";
         foreach ($aErrors as $aError) {
             $vBody .= $aError['feed'] . ' - ' . $aError['sku'] . ' - ' . $aError['message'] . "\n";
         }
     }
     if ($vBody !== '') {
         $aTo = Mage::getStoreConfig(self::CONFIG_EMAIL_TO_ADDRESS);
         if ($aTo == '') {
             return $this;
         } else {
             $aTo = explode(',', $aTo);
         }
         $mail = new Zend_Mail();
         $mail->setFrom(Mage::getStoreConfig(self::CONFIG_EMAIL_FROM_ADDRESS), Mage::getStoreConfig(self::CONFIG_EMAIL_FROM_NAME));
         $mail->addTo($aTo);
         $mail->setSubject("Feed Export Status Report");
         $mail->setBodyText($vBody);
         $mail->send();
     }
 }
 public function send()
 {
     $_helper = Mage::helper('smtppro');
     // If it's not enabled, just return the parent result.
     if (!$_helper->isEnabled()) {
         return parent::send();
     }
     if (Mage::getStoreConfigFlag('system/smtp/disable')) {
         return $this;
     }
     $mail = new Zend_Mail();
     if (strtolower($this->getType()) == 'html') {
         $mail->setBodyHtml($this->getBody());
     } else {
         $mail->setBodyText($this->getBody());
     }
     $mail->setFrom($this->getFromEmail(), $this->getFromName())->addTo($this->getToEmail(), $this->getToName())->setSubject($this->getSubject());
     $transport = new Varien_Object();
     // for observers to set if required
     Mage::dispatchEvent('aschroder_smtppro_before_send', array('mail' => $mail, 'email' => $this, 'transport' => $transport));
     if ($transport->getTransport()) {
         // if set by an observer, use it
         $mail->send($transport->getTransport());
     } else {
         $mail->send();
     }
     Mage::dispatchEvent('aschroder_smtppro_after_send', array('to' => $this->getToName(), 'subject' => $this->getSubject(), 'template' => "n/a", 'html' => strtolower($this->getType()) == 'html', 'email_body' => $this->getBody()));
     return $this;
 }
    /**
     * @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;
    }
Пример #7
0
 public function testSendMail()
 {
     $mail = new Zend_Mail();
     $mail->setBodyText('This mail should never be sent.');
     $mailTransport = new Centurion_Mail_Transport_Blackhole();
     $mailTransport->send($mail);
 }
Пример #8
0
 /**
  * Set mail options method
  *
  * @param string $body    Body string
  * @param array $from     Sender emails
  * @param array $addTo    Recipients emails
  * @param string $subject Subject of the mail
  */
 public static function setMailOptions($body, $from, $addTo, $subject)
 {
     if (self::$_mail == null) {
         self::_setMailObj();
     }
     // Validation Classes:
     $validMail = new Zend_Validate_EmailAddress();
     $validString = new Zend_Validate_StringLength(8);
     // Validate email body
     if ($validString->isValid($body)) {
         self::$_mail->setBodyText($body);
     } else {
         throw new Exception(implode($validString->getMessages(), '\\n'));
     }
     // Validate sender email
     if ($validMail->isValid($from)) {
         $emailFrom = $from;
     } else {
         throw new Exception(implode($validMail->getMessages(), '\\n'));
     }
     self::$_mail->setFrom($emailFrom);
     // Validate recipient email
     if ($validMail->isValid($addTo)) {
         $emailTo = $addTo;
     } else {
         throw new Exception(implode($validMail->getMessages(), '\\n'));
     }
     self::$_mail->addTo($emailTo);
     // Validte subject
     if ($validString->isValid($subject)) {
         self::$_mail->setSubject($subject);
     } else {
         throw new Exception(implode($validString->getMessages(), '\\n'));
     }
 }
Пример #9
0
 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;
 }
Пример #10
0
 public function sendAction()
 {
     // 返回值数组
     $result = array();
     // 请求参数
     // $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     /* $data = array(
                'subject'       => $request['subject'],
                'to'            => $request['to'],
                'to_name'       => $request['to_name'],
                'cc'            => $request['cc'],
                'cc_name'       => $request['cc_name'],
                'content'       => $request['content'],
                'attachment'    => $request['attachment']
        ); */
     $data = array('subject' => 'test', 'to' => '*****@*****.**', 'to_name' => '新大陆', 'cc' => '*****@*****.**', 'cc_name' => 'leon', 'content' => 'test123测试', 'charset' => 'utf-8', 'attachment' => null);
     echo '<pre>';
     print_r($data);
     $mailConfig = new Zend_Config_Ini(CONFIGS_PATH . '/application.ini', 'mail');
     $from = $mailConfig->smtp->from;
     $fromname = $mailConfig->smtp->fromname;
     $transport = new Zend_Mail_Transport_Smtp($mailConfig->smtp->server, $mailConfig->smtp->params->toArray());
     $mail = new Zend_Mail();
     $mail->setSubject($data['subject']);
     $mail->setBodyText($data['content'], $data['charset']);
     $mail->setFrom($from, $fromname);
     $mail->addTo($data['to'], $data['to_name']);
     $mail->addCc($data['cc'], $data['cc_name']);
     $mail->addAttachment('MailController.php');
     $mail->createAttachment(file_get_contents('E:\\sina.png'), 'image/png', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, 'sina.png');
     print_r($mail->send($transport));
     //echo Zend_Json::encode($result);
     exit;
 }
Пример #11
0
 /**
  * @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();
     }
 }
Пример #12
0
 public function send()
 {
     $bodyMessage = "MENSAGEM:\n        \n\t\t" . $this->_contactMail->getMessage() . "\n\n\t\tNOME DO CONTATO: " . $this->_contactMail->getName() . "\n\t\tE-MAIL PARA RESPOSTA: " . $this->_contactMail->getFrom() . "\n\n\t\tIP:{$_SERVER['REMOTE_ADDR']}";
     /*
      * send the email 
      */
     try {
         $mail = new Zend_Mail();
         $mail->setBodyText($bodyMessage);
         $mail->setFrom($this->_contactMail->getFrom(), $this->_contactMail->getName());
         $mail->addTo($this->_contactMail->getTo());
         $mail->setSubject($this->_contactMail->getSubject());
         $mail->send();
         // To sender
         // TODO internacionalization
         $bodyMessage = "Sua mensagem enviada como contato para " . $this->_contactMail->getTo() . ":\n                                " . $bodyMessage;
         $mail = new Zend_Mail();
         $mail->setBodyText($bodyMessage);
         $mail->setFrom($this->_contactMail->getFrom(), $this->_contactMail->getName());
         $mail->addTo($this->_contactMail->getFrom());
         $mail->setSubject($this->_contactMail->getSubject());
         $mail->send();
         return true;
     } catch (Exception $e) {
         throw new Zend_Exception("Site Contact Mail Error \n" . $e->getMessage());
     }
 }
Пример #13
0
 public function ceospeaksAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         // action body
         $emails_str = str_replace(" ", "", $request->getParam('emails'));
         // strips whitespace from string
         $emails = explode(",", $emails_str);
         // splits string into an array using comma to split
         $validator = new Zend_Validate_EmailAddress();
         foreach ($emails as $email) {
             if (!$validator->isValid($email)) {
                 array_shift($emails);
                 // Remove invalid emails
             }
         }
         $mail = new Zend_Mail();
         $mail->setFrom('*****@*****.**', 'winsandwants.com');
         $mail->setReplyTo('*****@*****.**', 'winsandwants.com');
         $mail->addTo($emails);
         $mail->setSubject('Sharing winsandwants.com');
         $txt = "A friend would like to share with you this wonderful free site on goal-setting and the mastermind concept. Please visit: http://winsandwants.com";
         $mail->setBodyText($txt, 'UTF-8');
         $mail->send();
         $this->view->msg = "Thank you for sharing this site. A link to this site has been sent to the following emails: " . implode(",", $emails) . ".";
     }
 }
Пример #14
0
 /**
  * @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;
 }
 public function answerAction()
 {
     $request = $this->getRequest();
     $table = new ZfBlank_DbTable_Feedback();
     if ($request->isPost()) {
         $post = $request->getPost();
         $msg = $table->find($post['id'])->getRow(0);
         if ($msg->validateForm($post, new Admin_Form_Feedback())) {
             $msg->setFromForm()->save();
             if ($post['sendAnswer']) {
                 $mail = new Zend_Mail('UTF-8');
                 $mail->addTo($msg->getAuthor(), $msg->getContact());
                 $mail->setFrom($this->_adminAddress, $this->_adminBot);
                 $mail->setSubject('Answer on your message');
                 $mailText = "Message text (TODO)";
                 $mail->setBodyText($mailText);
                 //$mail->send();
             }
             $this->_redirect('/admin/feedback/index/type/unanswered');
         }
         $this->view->form = $msg->form();
     } else {
         $msg = $table->find($request->getParam('id'))->getRow(0);
         $form = new Admin_Form_Feedback();
         $form->setDefaults($msg->getValues());
         $this->view->form = $form;
     }
 }
Пример #16
0
 /**
  * Return a new zend mail instance
  *
  * @return Zend_Mail
  */
 protected function getMail()
 {
     $mail = new Zend_Mail();
     $mail->setSubject('Subject');
     $mail->setBodyText('Body');
     return $mail;
 }
Пример #17
0
 function testemailJsonAction()
 {
     //TODO: all this code below is a temp code - we need to delete is later
     //and create new one in EmailNotification module
     $email = $this->_getParam('email');
     if ($email === null) {
         return array('data' => array('success' => false));
     }
     $configModel = new RM_Config();
     $mail = new Zend_Mail('UTF-8');
     $mail->addTo($email);
     $mail->setFrom($configModel->getValue('rm_config_email_settings_mailfrom'), $configModel->getValue('rm_config_email_settings_fromname'));
     $mail->setBodyText($this->_translate->_('Admin.Config.Edit', 'TestEmailMessage'));
     $mail->setSubject($this->_translate->_('Admin.Config.Edit', 'TestEmailSubject'));
     $emailType = $configModel->getValue('rm_config_email_settings_mailer');
     try {
         if ($emailType == 'PHP') {
             $mail->send();
         } else {
             $smtpConfig = array('auth' => 'Login', 'username' => $configModel->getValue('rm_config_email_settings_smtpuser'), 'password' => $configModel->getValue('rm_config_email_settings_smtppass'), 'port' => $configModel->getValue('rm_config_email_settings_smtpport'));
             if ($configModel->getValue('rm_config_email_settings_smtpsecure') != "") {
                 $smtpConfig['ssl'] = strtolower($configModel->getValue('rm_config_email_settings_smtpsecure'));
             }
             $mail->send(new Zend_Mail_Transport_Smtp($configModel->getValue('rm_config_email_settings_smtphost'), $smtpConfig));
         }
     } catch (Zend_Mail_Exception $e) {
         return array('data' => array('success' => false, 'error' => $e->getMessage()));
     }
     return array('data' => array('success' => true));
 }
Пример #18
0
 public function sendAction()
 {
     $this->logger->entering();
     $this->logger->info('Get email from params');
     $email = $this->_getParam('email');
     $this->logger->info('Getting password for email');
     $users = new User();
     $where = $this->db->quoteInto('email = ?', $email);
     $user = $users->fetchRow($where);
     if ($user->id != null) {
         $this->logger->debug("Got user #{$user->id}");
         $this->logger->info('Sending password reminder');
         $mail = new Zend_Mail();
         $mail->setFrom('*****@*****.**', 'Some Sender');
         $mail->addTo($user->email, $user->name);
         $mail->setSubject("Your Swaplady Password");
         $mail->setBodyText("Hi {$user->name},\nHere's your swaplady password:\n{$user->password}\nPlease keep it safe and sound.");
         $mail->send();
         $this->flash->notice = "Your password has been emailed to {$user->email}";
         $this->_redirect('/session/new');
     } else {
         $this->logger->warn('Unknown email');
         $this->flash->notice = "Your email wasn't recognized, did you spell it right?";
         $this->_redirect('/password/forgot');
     }
     $this->logger->exiting();
 }
Пример #19
0
 /**
  * Send an email.
  *
  * @param array $params Config object.
  *  Required keys: to, subject, message
  *  Optional keys: replyTo
  * @param array $viewParams Any values you wish to send to the HTML mail template
  * @param array $attachments
  * @return bool
  */
 public function send(array $params, array $viewParams = array(), $attachments = array())
 {
     $this->_validateParams($params);
     $mail = new Zend_Mail($this->getCharacterEncoding());
     $mail->setSubject($params['subject']);
     $mail->setBodyText($this->_getPlainBodyText($params));
     $mail->setFrom($this->getFromAddress(), $this->getFromName());
     $mail->addTo($params['to']);
     $viewParams['subject'] = $params['subject'];
     if ($this->getHtmlTemplate()) {
         $viewParams['message'] = isset($params['message']) ? $params['message'] : '';
         $viewParams['htmlMessage'] = isset($params['htmlMessage']) ? $params['htmlMessage'] : '';
         $mail->setBodyHtml($this->_renderView($viewParams));
     } elseif (isset($params['htmlMessage'])) {
         $mail->setBodyHtml($params['htmlMessage']);
     }
     if (!empty($params['replyTo'])) {
         $mail->setReplyTo($params['replyTo']);
     }
     if (!empty($params['cc'])) {
         $mail->addCc($params['cc']);
     }
     if (!empty($params['bcc'])) {
         $mail->addBcc($params['bcc']);
     }
     $this->addAttachments($attachments);
     $mimeParts = array_map(array($this, '_attachmentToMimePart'), $this->_attachments);
     array_walk($mimeParts, array($mail, 'addAttachment'));
     return $mail->send($this->getTransport());
 }
Пример #20
0
 public function send()
 {
     if (!Mage::getStoreConfig('amsmtp/general/enable')) {
         return parent::send();
     }
     if (Mage::getStoreConfigFlag('system/smtp/disable')) {
         return $this;
     }
     Mage::helper('amsmtp')->debug('Ready to send e-mail at amsmtp/core_email::send()');
     $mail = new Zend_Mail();
     if (strtolower($this->getType()) == 'html') {
         $mail->setBodyHtml($this->getBody());
     } else {
         $mail->setBodyText($this->getBody());
     }
     $mail->setFrom($this->getFromEmail(), $this->getFromName())->addTo($this->getToEmail(), $this->getToName())->setSubject($this->getSubject());
     $logId = Mage::helper('amsmtp')->log(array('subject' => $this->getSubject(), 'body' => $this->getBody(), 'recipient_name' => $this->getToName(), 'recipient_email' => $this->getToEmail(), 'template_code' => 'none', 'status' => Amasty_Smtp_Model_Log::STATUS_PENDING));
     try {
         $transportFacade = Mage::getModel('amsmtp/transport');
         if (!Mage::getStoreConfig('amsmtp/general/disable_delivery')) {
             $mail->send($transportFacade->getTransport());
         } else {
             Mage::helper('amsmtp')->debug('Actual delivery disabled under settings.');
         }
         Mage::helper('amsmtp')->logStatusUpdate($logId, Amasty_Smtp_Model_Log::STATUS_SENT);
         Mage::helper('amsmtp')->debug('E-mail sent successfully at amsmtp/core_email::send().');
     } catch (Exception $e) {
         Mage::helper('amsmtp')->logStatusUpdate($logId, Amasty_Smtp_Model_Log::STATUS_FAILED);
         Mage::helper('amsmtp')->debug('Error sending e-mail: ' . $e->getMessage());
     }
     return $this;
 }
Пример #21
0
 /**
  * Sends mail to recipient(s) if log entries are present.  Note that both
  * plaintext and HTML portions of email are handled here.
  *
  * @return void
  */
 public function shutdown()
 {
     // If there are events to mail, use them as message body.  Otherwise,
     // there is no mail to be sent.
     if (empty($this->_eventsToMail)) {
         return;
     }
     if ($this->_subjectPrependText !== null) {
         // Tack on the summary of entries per-priority to the subject
         // line and set it on the Zend_Mail object.
         $numEntries = $this->_getFormattedNumEntriesPerPriority();
         $this->_mail->setSubject("{$this->_subjectPrependText} ({$numEntries})");
     }
     // Always provide events to mail as plaintext.
     $this->_mail->setBodyText(implode('', $this->_eventsToMail));
     // If a Zend_Layout instance is being used, set its "events"
     // value to the lines formatted for use with the layout.
     if ($this->_layout) {
         // Set the required "messages" value for the layout.  Here we
         // are assuming that the layout is for use with HTML.
         $this->_layout->events = implode('', $this->_layoutEventsToMail);
         $this->_mail->setBodyHtml($this->_layout->render());
     }
     // Finally, send the mail, but re-throw any exceptions at the
     // proper level of abstraction.
     try {
         $this->_mail->send();
     } catch (Exception $e) {
         throw new Zend_Log_Exception($e->getMessage(), $e->getCode());
     }
 }
Пример #22
0
 /**
  * Método Responsável pelo Envio
  * @return boolean
  * @throws Zend_Mail_Exception
  */
 public function envia()
 {
     try {
         //$oConteudoEmail = $this->oViewEmail->setScriptPath ($this->sTemplate);
         //if (isset($this->oDadosView->oArquivoAnexo)) {
         //
         //  $this->oEmail->createAttachment ($this->getArquivoAnexo());
         //}
         $sConteudoEmail = $this->oViewEmail->render(APPLICATION_PATH . '/../public/templates/' . $this->getTemplate());
         if ($this->getConfiguracaoEmail()->formato == 'html') {
             $this->oEmail->setBodyHtml($sConteudoEmail);
         } else {
             $this->oEmail->setBodyText($sConteudoEmail);
         }
         $this->oEmail->setFrom($this->oViewEmail->sEmailOrigem, $this->oViewEmail->sNomeOrigem);
         $this->oEmail->setReplyTo($this->oViewEmail->sEmailOrigem, $this->oViewEmail->sNomeOrigem);
         $this->oEmail->addTo($this->oViewEmail->sEmailDestino, $this->oViewEmail->sNomeDestino);
         $this->oEmail->setSubject($this->oViewEmail->sAssunto);
         $this->oEmail->send($this->getMetodoTransporte());
         $oRetorno->mensage = self::SUCESSO_ENVIO;
         $oRetorno->status = true;
         return $oRetorno;
     } catch (Zend_Mail_Exception $oErro) {
         throw new Zend_Mail_Exception($oErro);
     }
 }
Пример #23
0
 /**
  * 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);
         }
     }
 }
Пример #24
0
 public function contactAction()
 {
     $formContacto = new Default_Form_Contacto();
     $formContacto->setAction($this->view->url(array(), 'Contact'));
     if ($this->getRequest()->isPost()) {
         $formData = $this->_request->getPost();
         if (!$formContacto->isValid($formData)) {
             $this->view->formContacto = $formContacto;
             $formContacto->populate($formData);
         } else {
             $mensaje = "";
             foreach ($formData as $k => $v) {
                 if ($k != "guardar" or $k != "asunto") {
                     $mensaje .= ucfirst($k) . ': ' . $v . '   ';
                 }
             }
             $mail = new Zend_Mail();
             $mail->setBodyText($mensaje);
             $mail->setFrom('*****@*****.**', '[Intermodels-Info]');
             $mail->addTo('*****@*****.**', 'Contacto Intermodels');
             $mail->setSubject($formData['asunto']);
             $mail->send();
             $this->_flashMessenger->addSuccess('En breve nos pondremos en contacto con Ud.');
             $this->_redirect('/');
         }
     }
     $this->view->formContacto = $formContacto;
 }
Пример #25
0
 public function sendemailAction()
 {
     $mailaddress = $this->getRequest()->getPost("mailaddress");
     $firstname = $this->getRequest()->getPost("firstname");
     $surname = $this->getRequest()->getPost("surname");
     $subject = $this->getRequest()->getPost("subject");
     $message = $this->getRequest()->getPost("message");
     if ($mailaddress == "" || $firstname == "" || $surname == "" || $subject == "" || $message == "") {
         $this->_redirect('/liens/fail');
     }
     $key = $this->getRequest()->getPost("sendto");
     if (array_key_exists($key, $this->_sendto)) {
         $mail = new Zend_Mail('UTF-8');
         $mail->setBodyText($message)->setFrom($mailaddress, $firstname . ' ' . $surname)->addTo($this->_sendto[$key], $this->_names[$key])->setSubject($subject);
         $sent = $mail->send();
         if ($mail->send()) {
             $this->_redirect('/liens/successful');
         } else {
             $this->_redirect('/index');
             $this->_redirect('/liens/fail');
         }
     } else {
         $this->_redirect('/liens/fail/' . $key . array_key_exists($key, $this->_sendto));
     }
 }
Пример #26
0
 public function errorAction()
 {
     $this->view->headTitle(' - Error ', 'APPEND');
     $this->view->exception = $this->_getParam('error_handler')->exception;
     switch (get_class($this->view->exception)) {
         case 'Zend_Controller_Router_Exception':
             $this->getResponse()->setHttpResponseCode(404);
             break;
         default:
             $this->getResponse()->setHttpResponseCode(500);
             break;
     }
     $this->view->headLink()->appendStylesheet('/css/error/error.css');
     if (APPLICATION_ENVIRONMENT == 'production' && get_class($this->view->exception) != 'Zend_Controller_Router_Exception') {
         // mail the error to neil@yadda.co.za
         $mail = new Zend_Mail('utf-8');
         $mail->setFrom('*****@*****.**', 'yadda.');
         $mail->setSubject('Exception at ' . $_SERVER['REQUEST_URI']);
         $mail->addTo('*****@*****.**');
         ob_start();
         var_dump($this->view->exception);
         echo "\n\n";
         var_dump($_SERVER);
         $mail->setBodyText(ob_get_clean());
         try {
             $mail->send();
         } catch (Exception $e) {
             // ignore
         }
     }
 }
Пример #27
0
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $config = $registry->get('config');
     $request = $this->getRequest();
     if ($auth->hasIdentity()) {
         $this->_redirect($router->assemble(array(), "logout") . "?please", array("exit"));
     }
     $signUp = Ml_Model_SignUp::getInstance();
     $form = $signUp->signUpForm();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $data = $form->getValues();
         if (isset($data['invitecode'])) {
             $inviteCode = $data['invitecode'];
         } else {
             $inviteCode = false;
         }
         $newUserInfo = $signUp->newUser($data['name'], $data['email'], $inviteCode);
         $this->view->entry = $newUserInfo;
         $mail = new Zend_Mail();
         $mail->setBodyText($this->view->render("join/email.phtml"))->setFrom($config['robotEmail']['addr'], $config['robotEmail']['name'])->addTo($data['email'], $data['name'])->setSubject('Your new ' . $config['applicationname'] . ' account')->send();
         $this->view->success = true;
     } else {
         $this->view->signUpForm = $form;
     }
 }
Пример #28
0
 /**
  *  Send mail.
  *
  *  @access     public
  *  @param      object      $workload       Object with mail sender, receiver, subject and body
  *  @return     void
  *  @throws     InvalidArgumentException    if workload object has no sender
  *  @throws     InvalidArgumentException    if workload object has no receiver
  *  @throws     InvalidArgumentException    if workload object has no subject
  *  @throws     InvalidArgumentException    if workload object has no body
  */
 public function run($workload)
 {
     $smtpServer = $this->options['server'];
     $config = array();
     if ($this->options['auth']) {
         $config['auth'] = $this->options['auth'];
         $config['username'] = $this->options['username'];
         $config['password'] = $this->options['password'];
     }
     $transport = new Zend_Mail_Transport_Smtp($smtpServer, $config);
     if (is_object($workload)) {
         if (empty($workload->sender)) {
             throw new InvalidArgumentException('Workload is missing sender');
         }
         if (empty($workload->receiver)) {
             throw new InvalidArgumentException('Workload is missing receiver');
         }
         if (empty($workload->subject)) {
             throw new InvalidArgumentException('Workload is missing subject');
         }
         if (empty($workload->body)) {
             throw new InvalidArgumentException('Workload is missing body');
         }
         $mail = new Zend_Mail();
         $mail->setDefaultTransport($transport);
         $mail->addTo($workload->receiver);
         $mail->setSubject($workload->subject);
         $mail->setBodyText($workload->body);
         $mail->setFrom($workload->sender);
         $mail->send($transport);
         $this->logSuccess('Mail "' . $workload->subject . '" sent to ' . $workload->receiver);
     }
 }
Пример #29
0
 public function init()
 {
     $this->model = new ContactUsForm();
     if (isset($_POST['ContactUsForm'])) {
         $this->model->attributes = $_POST['ContactUsForm'];
         if ($this->model->validate()) {
             $this->successMessage = 'Your message has been sent, thank you';
             try {
                 include_once "Zend/Mail.php";
                 $contactName = strip_tags($this->model->name);
                 $staffMessage = "Name:\t" . $contactName . "\n" . "Tel:\t" . $this->model->telephone . "\n" . "Email:\t" . $this->model->email . "\n" . "Message:\n" . $this->model->message . "\n\n" . "Sent:\t" . date("d/m/Y H:i");
                 $mailToStaff = new Zend_Mail("UTF-8");
                 $mailToStaff->addTo($this->model->to . Yii::app()->params['contactUs']['email_hostname']);
                 $mailToStaff->setFrom($this->model->to . Yii::app()->params['contactUs']['email_hostname']);
                 $mailToStaff->setSubject("Message posted from Wooster & Stock Contact Page");
                 $mailToStaff->setBodyText($staffMessage);
                 $mailToStaff->send();
                 $mailToClient = new Zend_Mail('UTF-8');
                 $mailToClient->addTo($this->model->email, $contactName);
                 $mailToClient->setFrom($this->model->to . Yii::app()->params['contactUs']['email_hostname']);
                 $mailToClient->setSubject("Message posted from Wooster & Stock Contact Page");
                 $mailToClient->setBodyText($this->emailText('text', $this->model->email, $contactName));
                 $mailToClient->setBodyHtml($this->emailText('html', $this->model->email, $contactName));
                 $mailToClient->send();
             } catch (Exception $e) {
             }
             $this->model->unsetAttributes();
         }
     }
 }
Пример #30
0
Файл: Email.php Проект: ud223/yj
 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;
 }