Inheritance: extends Zend_Mime_Message
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     ProjectConfiguration::setupMailer();
     $queue_table = Doctrine::getTable('MailQueue');
     $queue = $queue_table->getPending($arguments['limit']);
     $done = array();
     $failed = array();
     foreach ($queue as $item) {
         try {
             $mail = new Zend_Mail('utf-8');
             $mail->setSubject($item['subject']);
             $mail->setBodyText($item['body']);
             array_map(array($mail, 'addTo'), explode(',', $item['recipients']));
             $mail->send();
             $done[] = $item['id'];
         } catch (Zend_Exception $e) {
             $failed[] = $item['id'];
         }
     }
     $queue_table->deleteItems($done);
     $queue_table->recordAttemps($failed);
     $this->logSection('mailer', sizeof($done) . ' emails sent');
     $this->logSection('mailer', sizeof($failed) . ' emails failed');
 }
Example #2
0
 public function sendMail(Zend_Mail $mail, $body, $headers)
 {
     /**
      * @todo error checking
      */
     mail(join(',', $mail->getRecipients()), $mail->getSubject(), $body, $headers);
 }
Example #3
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;
 }
 /**
  * Enter description here...
  *
  */
 public function createAction()
 {
     $this->requirePost();
     $form = $this->getNewResidentForm();
     if ($form->isValid($_POST)) {
         if (!Table_Residents::getInstance()->residentExists($form->getValue('email'))) {
             $data = $form->getValues();
             $password = rand(10000, 9999999);
             $data['password_hash'] = md5($password);
             unset($data['aufnehmen']);
             $newResident = Table_Residents::getInstance()->createRow($data);
             if ($newResident && $newResident->save()) {
                 $websiteUrl = Zend_Registry::get('configuration')->basepath;
                 $mailText = "Du wurdest in die WG aufgenommen.\n\t\t\t\t\tDu kannst dich nun unter {$websiteUrl}/session/new anmelden.\n\n\t\t\t\t\tDeine Zugangsdaten:\n\n\t\t\t\t\tEmail Addresse = {$newResident->email}\n\t\t\t\t\tPassword = {$password}";
                 $mail = new Zend_Mail();
                 $mail->addTo($newResident->email)->setSubject("Du wurdest in der WG aufgenomme!")->setBodyText($mailText);
                 $mail->send();
                 $this->flash('Der Bewohner mit der Email Addresse ' . $newResident->email . ' wurde erfolgreich eingetragen.');
                 $this->flash('Ein generiertes Passwort wurde per Email zugeschickt.');
                 $this->redirect('index');
             } else {
                 $this->flash('Es trat ein Fehler beim speichern des neuen Bewohners auf.');
                 $this->redirect('new');
             }
         } else {
             $this->flash('Ein Bewohner mit der Emailaddresse ' . $form->getValue('email') . ' existiert bereits.');
             $this->redirect('new');
         }
     } else {
         $this->redirect('new');
     }
 }
 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;
     }
 }
Example #6
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);
 }
Example #7
0
    public function indexAction()
    {
        $formulario = new Application_Form_Contacto();
        $modelo = new Application_Model_Contacto();
        if ($this->getRequest()->isPost()) {
            if ($formulario->isValid($this->_getAllParams())) {
                $modelo->grabarDatos($formulario->getValues());
                $alldata = $this->getAllParams();
                $mail = new Zend_Mail('UTF-8');
                $mail->setBodyHtml('Detalle del Contacto' . '<br>' . 'Nombre:' . $alldata['nombre'] . '<br>' . 'Cargo: ' . $alldata['cargo'] . '<br>' . 'Correo Electrónico: ' . $alldata['correo'] . '<br>' . 'Empresa:' . $alldata['empresa'] . '<br>' . 'Mensaje:' . $alldata['mensaje'] . '<br>');
                $mail->addTo('*****@*****.**', 'Grupo Inested Internacional Website');
                $mail->setSubject('Contacto Website Grupo Inested');
                $enviar = $mail->send();
                if ($enviar) {
                    $this->view->mensaje = '<div class="alert alert alert-success" color:black; height: 18px;">
														 <button type="button" class="close" data-dismiss="alert">&times;</button> 
														 Mensaje enviado con Éxito
												   </div>';
                    $formulario->reset();
                } else {
                    $this->view->mensaje = '<div class="alert alert-error" color:black; height: 18px;">
														 <button type="button" class="close" data-dismiss="alert">&times;</button> 
														 Error, no se pudo enviar el mensaje
												   </div>';
                    $formulario->reset();
                }
            }
        }
        $this->view->contacto = $formulario;
        $this->view->powered = '<h6> Desarrollado por <a href="http://www.gimalca.com/">Gimalca Soluciones</a></h6>';
    }
Example #8
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;
 }
    public function indexAction()
    {
        $this->view->headTitle('Contato');
        $categoriaModel = new Application_Model_Categoria();
        $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
        $this->view->categorias = $nome_categorias;
        require_once APPLICATION_PATH . '/forms/Contato.php';
        $this->view->form = new Application_Form_Contato();
        if ($this->_request->isPost()) {
            $this->view->form->setDefaults($this->_request->getPost());
            $data = $this->view->form->getValues();
            if ($this->view->form->isValid($data)) {
                $contatosModel = new Application_Model_Contatos();
                $id = $contatosModel->insert($data);
                $data = '<html><body><table>
					<tr><td>Nome</td>
					<td>' . $_POST['nome'] . '</td></tr>
					<tr><td>E-mail</td>
					<td>' . $_POST['email'] . '</td></tr>
					<tr><td>Telefone</td>
					<td>' . $_POST['telefone'] . '</td></tr>
					<tr><td>Texto</td>
					<td>' . $_POST['mensagem'] . '</td></tr>
					</table></body></html>';
                // Using the ini_set()
                ini_set("SMTP", "localhost");
                ini_set("sendmail_from", "*****@*****.**");
                ini_set("smtp_port", "587");
                $mail = new Zend_Mail('UTF-8', 'ISO-8859-8');
                $mail->setBodyHtml($data)->setFrom('*****@*****.**', 'Formulario de Contato')->addTo('*****@*****.**', 'Contato')->setSubject('Contato')->send();
                return $this->_helper->redirector('index');
            }
        }
    }
Example #10
0
 private function __construct()
 {
     // setup file error logging
     $file_writer = new Logger_Errorlog();
     if (Config::get_optional("DEBUG_LOG") == false) {
         $file_writer->addFilter(Zend_Log::INFO);
     }
     $log = new Zend_Log();
     $log->addWriter($file_writer);
     // setup email error logging
     if (Config::get_optional("log_to_email") == true) {
         $mail = new Zend_Mail();
         $mail->setFrom(Config::get_mandatory('log_email_from'));
         $mail->addTo(Config::get_mandatory('log_email_to'));
         // setup email template
         $layout = new Zend_Layout();
         $layout->setLayoutPath(DOCUMENT_ROOT . Config::get_mandatory("log_email_template"));
         $layout->setLayout('error-logger');
         $layout_formatter = new Zend_Log_Formatter_Simple('<li>.' . Zend_Log_Formatter_Simple::DEFAULT_FORMAT . '</li>');
         // Use default HTML layout.
         $email_writer = new Zend_Log_Writer_Mail($mail, $layout);
         $email_writer->setLayoutFormatter($layout_formatter);
         $email_writer->setSubjectPrependText(Config::get_mandatory('log_email_subject_prepend'));
         $email_writer->addFilter(Zend_Log::ERR);
         $log->addWriter($email_writer);
     }
     self::$logger = $log;
 }
    /**
     * @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;
    }
Example #12
0
 /**
  * 
  * @param User_Form_Recovery $form
  * @return boolean
  */
 public function userRecovery(User_Form_Recovery $form)
 {
     $answer = false;
     $user = Doctrine_Query::create()->from('User_Model_Mapper_User u')->select('u.username')->addSelect('u.password')->where('u.username = ?', $form->getValue('username'));
     if ($user->count() != '0') {
         $userRecovery = $user->fetchOne();
         $ranges = array(range('a', 'z'), range('A', 'Z'), range(1, 9));
         $length = 8;
         $pass = '';
         for ($i = 0; $i < $length; $i++) {
             $rkey = array_rand($ranges);
             $vkey = array_rand($ranges[$rkey]);
             $pass .= $ranges[$rkey][$vkey];
         }
         $hash = sha1($pass);
         $userRecovery->password = $hash;
         $userRecovery->save();
         $mail = new Zend_Mail();
         $mail->setBodyHtml('<p>Your new password.</p><p>Password: '******'</p>');
         $mail->setFrom('*****@*****.**', 'Administrator');
         $mail->addTo($userRecovery->email, $userRecovery->username);
         $mail->setSubject('Test password recovery');
         $mail->send();
         $answer = true;
     }
     return $answer;
 }
Example #13
0
 public function sendAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     if ($this->getRequest()->isPost()) {
         $name = $this->getRequest()->getPost('Name');
         $email = $this->getRequest()->getPost('Email');
         $subject = $this->getRequest()->getPost('Subject');
         $content = $this->getRequest()->getPost('Content');
         $html = $content;
         $mail = new Zend_Mail();
         $mail->addTo($email, $name)->setSubject($subject)->setBodyHtml($html);
         if ($mail->send()) {
             $status = 'Success';
             $msg = 'Send email success.';
         } else {
             $status = 'Error';
             $msg = 'Send email fault.';
         }
     } else {
         $status = 'Error';
         $msg = 'Not found POST value.';
     }
     echo Zend_Json::encode(array('status' => $status, 'msg' => $msg));
 }
Example #14
0
 /**
  * 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);
 }
Example #15
0
function sendmail($subject, $mailcontent, $receiver, $receivername, $attachment = "")
{
    //die($subject." | ".$mailcontent." | ".$receiver." | ".$receivername);
    try {
        $mail = new Zend_Mail();
        $mail->setBodyHtml($mailcontent)->setFrom('*****@*****.**', 'Pepool')->addTo($receiver, $receivername)->setSubject($subject)->send();
    } catch (Zend_Exception $e) {
    }
    /*
    if(strpos($_SERVER['HTTP_HOST'],"localhost"))return false;
    $mail = new phpmailer();
    $mail->IsSMTP();
    $mail->Subject  =  $subject;
    $mail->Body  = $mailcontent;
    $mail->AddAddress($receiver, $receivername);
    $mail->IsHTML(true);
    if($attachment != '')$mail->AddAttachment($attachment);
    
    if(!$mail->Send())
    {
    	$headers  = 'MIME-Version: 1.0' . "\r\n";
    	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    	$headers .= "To: $receivername <$receiver>" . "\r\n";
    	$headers .= "From: Pepool <*****@*****.**>" . "\r\n";
    	mail($receiver, $subject, $mailcontent, $headers);
    }
    */
    return true;
}
Example #16
0
 protected function _sendEmail(array $email, array $user, Zend_Mail_Transport_Abstract $transport)
 {
     if (!$user['email']) {
         return;
     }
     $phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($email['email_title'] . $email['email_body']);
     /** @var XenForo_Model_Phrase $phraseModel */
     $phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
     $phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
     foreach ($phraseTitles as $search => $phraseTitle) {
         if (isset($phrases[$phraseTitle])) {
             $email['email_title'] = str_replace($search, $phrases[$phraseTitle], $email['email_title']);
             $email['email_body'] = str_replace($search, $phrases[$phraseTitle], $email['email_body']);
         }
     }
     $mailObj = new Zend_Mail('utf-8');
     $mailObj->setSubject($email['email_title'])->addTo($user['email'], $user['username'])->setFrom($email['from_email'], $email['from_name']);
     $options = XenForo_Application::getOptions();
     $bounceEmailAddress = $options->bounceEmailAddress;
     if (!$bounceEmailAddress) {
         $bounceEmailAddress = $options->defaultEmailAddress;
     }
     $toEmail = $user['email'];
     $bounceHmac = substr(hash_hmac('md5', $toEmail, XenForo_Application::getConfig()->globalSalt), 0, 8);
     $mailObj->addHeader('X-To-Validate', "{$bounceHmac}+{$toEmail}");
     if ($options->enableVerp) {
         $verpValue = str_replace('@', '=', $toEmail);
         $bounceEmailAddress = str_replace('@', "+{$bounceHmac}+{$verpValue}@", $bounceEmailAddress);
     }
     $mailObj->setReturnPath($bounceEmailAddress);
     if ($email['email_format'] == 'html') {
         $replacements = array('{name}' => htmlspecialchars($user['username']), '{email}' => htmlspecialchars($user['email']), '{id}' => $user['user_id']);
         $email['email_body'] = strtr($email['email_body'], $replacements);
         $text = trim(htmlspecialchars_decode(strip_tags($email['email_body'])));
         $mailObj->setBodyHtml($email['email_body'])->setBodyText($text);
     } else {
         $replacements = array('{name}' => $user['username'], '{email}' => $user['email'], '{id}' => $user['user_id']);
         $email['email_body'] = strtr($email['email_body'], $replacements);
         $mailObj->setBodyText($email['email_body']);
     }
     if (!$mailObj->getMessageId()) {
         $mailObj->setMessageId();
     }
     $thisTransport = XenForo_Mail::getFinalTransportForMail($mailObj, $transport);
     try {
         $mailObj->send($thisTransport);
     } catch (Exception $e) {
         if (method_exists($thisTransport, 'resetConnection')) {
             XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
             $thisTransport->resetConnection();
             try {
                 $mailObj->send($thisTransport);
             } catch (Exception $e) {
                 XenForo_Error::logException($e, false, "Email to {$user['email']} failed (after retry): ");
             }
         } else {
             XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
         }
     }
 }
 private function GetEmailAddresses($s_sql, Zend_Mail $email)
 {
     $a_send = null;
     if ($s_sql) {
         $result = $this->GetDataConnection()->query($s_sql);
         while ($o_row = $result->fetch()) {
             # first up, if this is a review item, get the title
             if (isset($o_row->title)) {
                 $this->s_review_item_title = $o_row->title;
             }
             # check if person in the previous subscriptions
             if (!is_array($this->a_emails) or !in_array($o_row->email, $this->a_emails)) {
                 #...add to email list
                 $a_send[] = $o_row->email;
                 # ... add also to list of people sent, to exclude from further emails
                 $this->a_emails[] = $o_row->email;
             }
         }
         $result->closeCursor();
         if (is_array($a_send)) {
             foreach ($a_send as $address) {
                 $email->addBcc($address);
             }
         }
     }
     return is_array($a_send);
 }
Example #18
0
 public function recoveryPasswordCliente($email)
 {
     try {
         if ($this->_modelUser->verificarEmail($email) == true) {
             try {
                 $where = $this->_modelUser->getAdapter()->quoteInto('email = ?', $email);
                 $user = $this->_modelUser->fetchAll($where);
                 $html = new Zend_View();
                 $html->setScriptPath(APPLICATION_PATH . '/assets/templates/');
                 // enviando variaveis para a view
                 $html->assign('nome', $user[0]['nome']);
                 $html->assign('email', $user[0]['email']);
                 $html->assign('senha', $user[0]['passw']);
                 // criando objeto email
                 $mail = new Zend_Mail('utf-8');
                 // render view
                 $bodyText = $html->render('esqueciasenha.phtml');
                 // configurar envio
                 $mail->addTo($user[0]['email']);
                 $mail->setSubject('Esqueci a senha ');
                 $mail->setFrom('*****@*****.**', 'Resort Villa Hípica');
                 $mail->setBodyHtml($bodyText);
                 $mail->send();
                 return true;
             } catch (Exception $e) {
                 throw $e;
             }
         } else {
             return false;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #19
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;
 }
Example #20
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;
 }
Example #21
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));
     }
 }
Example #22
0
 /**
  * Executes feedback action
  *
  */
 public function executeFeedback(sfRequest $request)
 {
     $section = $request->getParameter('section', false);
     $this->form = new aFeedbackForm($section);
     $this->feedbackSubmittedBy = false;
     $this->failed = false;
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag', 'Url'));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('feedback'), $request->getFiles('feedback'));
         // $this->form->bind(array_merge($request->getParameter('feedback'), array('captcha' => $request->getParameter('captcha'))), $request->getFiles('feedback'));
         if ($this->form->isValid()) {
             $feedback = $this->form->getValues();
             $feedback['browser'] = $_SERVER['HTTP_USER_AGENT'];
             try {
                 aZendSearch::registerZend();
                 $mail = new Zend_Mail();
                 $mail->setBodyText($this->getPartial('feedbackEmailText', array('feedback' => $feedback)))->setFrom($feedback['email'], $feedback['name'])->addTo(sfConfig::get('app_aFeedback_email_auto'))->setSubject($this->form->getValue('subject', 'New aBugReport submission'));
                 if ($screenshot = $this->form->getValue('screenshot')) {
                     $mail->createAttachment(file_get_contents($screenshot->getTempName()), $screenshot->getType());
                 }
                 $mail->send();
                 // A new form for a new submission
                 $this->form = new aFeedbackForm();
             } catch (Exception $e) {
                 $this->logMessage('Request email failed: ' . $e->getMessage(), 'err');
                 $this->failed = true;
                 return 'Success';
             }
             $this->getUser()->setFlash('reportSubmittedBy', $feedback['name']);
             $this->redirect($feedback['section']);
         }
     }
 }
Example #23
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;
     }
 }
Example #24
0
 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;
 }
 private function SEND_SMTP_ZEND()
 {
     try {
         loadLibrary("ZEND", "Zend_Mail");
         loadLibrary("ZEND", "Zend_Mail_Transport_Smtp");
         if (empty($this->MailText)) {
             $this->MailText = ">>";
         }
         if ($this->Account->Authentication == "No") {
             $config = array('port' => $this->Account->Port);
         } else {
             $config = array('auth' => 'login', 'username' => $this->Account->Username, 'password' => $this->Account->Password, 'port' => $this->Account->Port);
         }
         if (!empty($this->Account->SSL)) {
             $config['ssl'] = $this->Account->SSL == 1 ? 'SSL' : 'TLS';
         }
         $transport = new Zend_Mail_Transport_Smtp($this->Account->Host, $config);
         $mail = new Zend_Mail('UTF-8');
         $mail->setBodyText($this->MailText);
         $mail->setFrom($this->Account->Email, $this->Account->SenderName);
         if (strpos($this->Receiver, ",") !== false) {
             $emails = explode(",", $this->Receiver);
             $add = false;
             foreach ($emails as $mailrec) {
                 if (!empty($mailrec)) {
                     if (!$add) {
                         $add = true;
                         $mail->addTo($mailrec, $mailrec);
                     } else {
                         $mail->addBcc($mailrec, $mailrec);
                     }
                 }
             }
         } else {
             $mail->addTo($this->Receiver, $this->Receiver);
         }
         $mail->setSubject($this->Subject);
         $mail->setReplyTo($this->ReplyTo, $name = null);
         if ($this->Attachments != null) {
             foreach ($this->Attachments as $resId) {
                 $res = getResource($resId);
                 $at = $mail->createAttachment(file_get_contents("./uploads/" . $res["value"]));
                 $at->type = 'application/octet-stream';
                 $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                 $at->encoding = Zend_Mime::ENCODING_BASE64;
                 $at->filename = $res["title"];
             }
         }
         $mail->send($transport);
     } catch (Exception $e) {
         if ($this->TestIt) {
             throw $e;
         } else {
             handleError("111", $this->Account->Host . " send mail connection error: " . $e->getMessage(), "functions.global.inc.php", 0);
         }
         return 0;
     }
     return 1;
 }
Example #26
0
 function send()
 {
     $this->save();
     // save
     $SET = G()->SET['qg']['mail'];
     require_once sysPATH . 'Zend/Mail.php';
     if (G()->SET['qg']['mail']['smtp']['host']->v) {
         require_once sysPATH . 'Zend/Mail/Transport/Smtp.php';
         $config = array('ssl' => 'tls');
         if ($SET['smtp']['port']->v) {
             $config['port'] = $SET['smtp']['port']->v;
         }
         if ($SET['smtp']['username']->v) {
             $config['auth'] = 'login';
             $config['username'] = $SET['smtp']['username']->v;
             $config['password'] = $SET['smtp']['password']->v;
         }
         $tr = new \Zend_Mail_Transport_Smtp($SET['smtp']['host']->v, $config);
     } else {
         require_once sysPATH . 'Zend/Mail/Transport/Sendmail.php';
         $tr = new \Zend_Mail_Transport_Sendmail('-f' . $SET['replay']->v);
     }
     \Zend_Mail::setDefaultTransport($tr);
     $toWebmaster = debug ? $SET['on debugmode to']->v : false;
     foreach (D()->mail_recipient->selectEntries("WHERE mail_id = " . $this . " AND sent = 0") as $Item) {
         $ZendMail = new \Zend_Mail('utf-8');
         $ZendMail->setFrom($this->sender, $this->sendername ? $this->sendername : $this->sender);
         $ZendMail->setSubject(($toWebmaster ? 'Debug! ' : '') . $this->subject);
         $html = $this->getHtml($Item, $ZendMail);
         // dirty hack for thunderbird, it needs multipart/related for inline-images
         if (strpos($html, 'cid:') !== false) {
             $ZendMail->setType(Zend_Mime::MULTIPART_RELATED);
             // ok?
         }
         $ZendMail->setBodyHtml(($toWebmaster ? 'original receiver :' . $Item->email . '<br><br>' : '') . $html);
         $ZendMail->setBodyText(($toWebmaster ? 'original receiver :' . $Item->email . "\n\n" : '') . $this->getText($Item, $ZendMail));
         $ZendMail->addTo($toWebmaster ? $toWebmaster : $Item->email, $Item->name);
         foreach (D()->query("SELECT * FROM mail_attachment WHERE mail_id = " . $this->id) as $vs) {
             $At = $ZendMail->createAttachment(file_get_contents($vs['path']));
             $At->filename = $vs['name'] ? $vs['name'] : basename($vs['path']);
             $At->type = $vs['type'] ? $vs['type'] : File::extensionToMime(preg_replace('/.*\\.([^.]+$)/', '$1', $vs['path']));
             $At->disposition = $vs['inline'] ? Zend_Mime::DISPOSITION_INLINE : Zend_Mime::DISPOSITION_ATTACHMENT;
             $At->id = $vs['hash'];
         }
         $sent = false;
         try {
             $sent = $ZendMail->send();
         } catch (Exception $e) {
             var_dump($this->sender);
             trigger_error('mail sending failed :' . $e);
         }
         if ($sent) {
             $Item->sent = time();
             $Item->save();
             // save
         }
     }
 }
Example #27
0
 /**
  * Sends the contact request to the configured contact email address.
  *
  * @throws Exception when contact email is not configured
  */
 public function send()
 {
     $contactEmail = Setting::getKey('address', 'contact');
     if (null === $contactEmail) {
         throw new Exception('Contact email not configured');
     }
     $mail = new Zend_Mail();
     $mail->setSubject('Contact request')->setFrom($this->email, $this->name)->setBodyText($this->body)->addTo($contactEmail)->send();
 }
Example #28
0
 public function shutdown()
 {
     if (count($this->_events) == 0) {
         return;
     }
     $subject = sprintf('web site log messages(%d)', count($this->_events));
     $mail = new Zend_Mail();
     $mail->addTo($this->_email)->setSubject($subject)->setBodyText(join(' ', $this->_events))->send();
 }
 /**
  * @group ZF-8988
  */
 public function testReturnPathIsUsedAsMailFrom()
 {
     $connectionMock = $this->getMock('Zend_Mail_Protocol_Smtp');
     $connectionMock->expects($this->once())->method('mail')->with('*****@*****.**');
     $transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
     $transport->setConnection($connectionMock);
     $mail = new Zend_Mail();
     $mail->setBodyText('This is a test.')->setFrom('*****@*****.**', 'from user')->setReturnPath('*****@*****.**');
     $mail->send($transport);
 }
Example #30
0
 protected function getMail()
 {
     if ((bool) $this->config->mail['smtp']) {
         # use smtp
         \Zend_Mail::setDefaultTransport(new \Zend_Mail_Transport_Smtp($this->config->mail['smtp_host'], $this->config->mail['config']));
     }
     $mail = new \Zend_Mail();
     $mail->setFrom($this->config->mail['send_email'], $this->config->mail['name_service']);
     return $mail;
 }