public function __construct($isException = false) { // Configuração de remetente $config = RW_Config::getApplicationIni(); $this->_name = $config->cms->email->name; $this->_email = $config->cms->email->email; $this->_returnPath = $config->cms->email->returnPath; // Verifica se está em ambiente de teste if (APPLICATION_ENV != 'production') { $this->_name .= ' (teste local)'; $this->_email = '*****@*****.**'; } // Configuração de envio de email $default = Zend_Mail::getDefaultTransport(); // Verifica se há transport a ser usado if (empty($default)) { if ($isException instanceof Zend_Mail_Transport_Abstract) { $transport = $isException; } else { $this->_type = $isException ? 'exception' : $config->cms->email->type; $this->_username = isset($config->cms->email->smtp) ? $config->cms->email->smtp->username : ''; $this->_password = isset($config->cms->email->smtp) ? $config->cms->email->smtp->password : ''; // Configura o método de envio if ($this->_type == 'exception') { $transport = new Zend_Mail_Transport_Sendmail('-f' . $this->_returnPath); // Envio do servidor local. Deve impedir que o cliente receba sem querer } elseif (APPLICATION_ENV != 'production') { $transport = new Zend_Mail_Transport_Sendmail("*****@*****.**"); // Configurações da Locaweb } elseif ($this->_type == 'locaweb') { /* * Return-Path padrão da Locaweb * sendmail_path = /usr/sbin/sendmail -t -i -r'*****@*****.**' */ $transport = new Zend_Mail_Transport_Sendmail("-f{$this->_returnPath}"); // Configurações do GMail } elseif ($this->_type == 'gmail') { $serverconfig = array('auth' => 'login', 'username' => $this->_username, 'password' => $this->_password, 'ssl' => 'ssl', 'port' => 465); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $serverconfig); // Configuração genérica de SMTP } elseif ($this->_type == 'smtp') { $serverconfig = array('auth' => 'login', 'username' => $this->_username, 'password' => $this->_password); // Verifica se há SSL if (isset($config->cms->email->smtp->ssl) && $config->cms->email->smtp->ssl != '') { $serverconfig['ssl'] = $config->cms->email->smtp->ssl; } // veriufica se há uma porta definida if (isset($config->cms->email->smtp->port) && $config->cms->email->smtp->port != '') { $serverconfig['port'] = $config->cms->email->smtp->port; } // Configura o transport $transport = new Zend_Mail_Transport_Smtp($config->cms->email->smtp->host, $serverconfig); } else { throw new Exception('Tipo de envio <b>' . $this->_type . '</b> não definido em RW_Mail'); } } // Grava o transport a ser usado para envio de emails Zend_Mail::setDefaultTransport($transport); } }
protected function setUp() { // backup static vars $this->_oldTransport = Zend_Mail::getDefaultTransport(); $this->_oldFrom = Zend_Mail::getDefaultFrom(); // set mail transport to testing Zend_Mail::setDefaultTransport($this->_transport = new Zle_Mail_Transport_Testing()); }
/** * Get email headers * * @return array */ private function getEmailHeaders() { $transport = \Zend_Mail::getDefaultTransport(); $headers = array(); foreach (explode("\n", $transport->header) as $line) { if (strpos($line, ':') !== false) { list($name, $value) = explode(':', $line); $headers[$name] = $value; } } return $headers; }
protected function _setTransportType() { $defaultTransportType = Zend_Mail::getDefaultTransport(); if ($defaultTransportType instanceof Zend_Mail_Transport_File) { $transportType = Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_FILE; } else { if ($defaultTransportType instanceof Zend_Mail_Transport_Smtp) { $transportType = Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_SMTP; } else { $transportType = Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_DEFAULT; } } $this->getSentEmailModel()->setTransportType($transportType); return $this; }
/** * @group ZF-8981 */ public function testNumericRegisterDirectiveIsPassedOnCorrectly() { $options = array('transport' => array('type' => 'sendmail', 'register' => '1')); // Culprit $resource = new Zend_Application_Resource_Mail(array()); $resource->setBootstrap($this->bootstrap); $resource->setOptions($options); $resource->init(); $this->assertTrue(Zend_Mail::getDefaultTransport() instanceof Zend_Mail_Transport_Sendmail); }
/** * Gets the transport that will be used to send XF mails. * This will reflect explicit overrides that the get default method won't. * * @return Zend_Mail_Transport_Abstract */ public static function getTransport() { if (!self::$_transportSetup) { self::setupTransport(); } return Zend_Mail::getDefaultTransport(); }