Esempio n. 1
0
 public function flush()
 {
     $this->transport->setOptions($this->getSmtpOptions());
     foreach ($this->queue as $message) {
         $this->transport->send($message);
     }
     $this->queue = [];
 }
Esempio n. 2
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $sm Service manager
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $sm)
 {
     // Load configurations:
     $config = $sm->get('VuFind\\Config')->get('config');
     // Create mail transport:
     $settings = ['host' => $config->Mail->host, 'port' => $config->Mail->port];
     if (isset($config->Mail->username) && isset($config->Mail->password)) {
         $settings['connection_class'] = 'login';
         $settings['connection_config'] = ['username' => $config->Mail->username, 'password' => $config->Mail->password];
         if (isset($config->Mail->secure)) {
             // always set user defined secure connection
             $settings['connection_config']['ssl'] = $config->Mail->secure;
         } else {
             // set default secure connection based on configured port
             if ($settings['port'] == '587') {
                 $settings['connection_config']['ssl'] = 'tls';
             } elseif ($settings['port'] == '487') {
                 $settings['connection_config']['ssl'] = 'ssl';
             }
         }
     }
     $transport = new Smtp();
     $transport->setOptions(new SmtpOptions($settings));
     // Create service:
     return new \VuFind\Mailer\Mailer($transport);
 }
Esempio n. 3
0
 public static function getMailerObject()
 {
     $response = array();
     $response['mail'] = new Message();
     $response['mail']->setEncoding(APP_CHARSET);
     if (strcasecmp(Config::get('concrete.mail.method'), 'smtp') == 0) {
         $config = array('host' => Config::get('concrete.mail.methods.smtp.server'));
         $username = Config::get('concrete.mail.methods.smtp.username');
         $password = Config::get('concrete.mail.methods.smtp.password');
         if ($username != '') {
             $config['connection_class'] = 'login';
             $config['connection_config'] = array();
             $config['connection_config']['username'] = $username;
             $config['connection_config']['password'] = $password;
         }
         $port = Config::get('concrete.mail.methods.smtp.port', '');
         if ($port != '') {
             $config['port'] = $port;
         }
         $encr = Config::get('concrete.mail.methods.smtp.encryption', '');
         if ($encr != '') {
             $config['connection_config']['ssl'] = $encr;
         }
         $transport = new SmtpTransport();
         $options = new SmtpOptions($config);
         $transport->setOptions($options);
         $response['transport'] = $transport;
     } else {
         $response['transport'] = new SendmailTransport();
     }
     return $response;
 }
Esempio n. 4
0
 protected function send()
 {
     try {
         $message = new Message();
         $para = array_filter(explode(";", str_replace(array(" ", ","), array("", ";"), $this->dados["para"])));
         $message->addTo($para)->addFrom($this->dados["de"]["email"], $this->dados["de"]["nome"])->setSubject($this->dados["assunto"])->addReplyTo($this->dados["replay"]);
         $transport = new SmtpTransport();
         $options = new SmtpOptions(array('host' => 'mail.pessoaweb.com.br', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'd1i2s3p4atch'), 'port' => 587));
         $html = new MimePart($this->dados["body"]);
         $html->type = "text/html";
         $html->charset = "UTF-8";
         $body = new MimeMessage();
         if (isset($this->dados["attachment"])) {
             foreach ($this->dados["attachment"] as $valor) {
                 $attachment = new MimePart($valor["arquivo"]);
                 $attachment->filename = $valor["titulo"];
                 if (isset($valor["tipo"])) {
                     $attachment->type = $valor["tipo"];
                 }
                 $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
                 $attachment->encoding = Mime::ENCODING_BASE64;
                 $body->setParts(array($attachment));
             }
         }
         $body->addPart($html);
         $message->setBody($body);
         $transport->setOptions($options);
         $transport->send($message);
         return $transport;
     } catch (\Exception $e) {
         debug(array("email" => $e->getMessage()), true);
     }
 }
Esempio n. 5
0
 public function getTransport()
 {
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'bitweb.ee', 'host' => 'smtp.gmail.com', 'port' => '25', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => 'erkinool123')));
     $transport->setOptions($options);
     return $transport;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $transport = new Smtp();
     $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
     return $transport;
 }
Esempio n. 7
0
 /**
  * Sends a mail with the given data from the AppMailAccount
  * @param string $to
  * @param string $subject
  * @param string $content
  */
 public function sendMail(string $to, string $subject, string $content, array $files = [])
 {
     $content .= "\n\nThis is an automated mail. Please don't respond.";
     $text = new Mime\Part($content);
     $text->type = 'text/plain';
     $text->charset = 'utf-8';
     $text->disposition = Mime\Mime::DISPOSITION_INLINE;
     $parts[] = $text;
     foreach ($files as $filePath) {
         $fileContent = file_get_contents($filePath);
         $attachment = new Mime\Part($fileContent);
         $attachment->type = 'image/' . pathinfo($filePath, PATHINFO_EXTENSION);
         $attachment->filename = basename($filePath);
         $attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $attachment->encoding = Mime\Mime::ENCODING_BASE64;
         $parts[] = $attachment;
     }
     $mime = new Mime\Message();
     $mime->setParts($parts);
     $appMailData = $this->getAppMailData();
     $message = new Message();
     $message->addTo($to)->addFrom($appMailData->getAdress())->setSubject($subject)->setBody($mime)->setEncoding('utf-8');
     $transport = new SmtpTransport();
     $options = new SmtpOptions(['name' => $appMailData->getHost(), 'host' => $appMailData->getHost(), 'connection_class' => 'login', 'connection_config' => ['username' => $appMailData->getLogin(), 'password' => $appMailData->getPassword()]]);
     $transport->setOptions($options);
     $transport->send($message);
 }
Esempio n. 8
0
 /**
  * Prepares the \Zend\Mail module
  */
 public function __construct()
 {
     $beehubConfig = \BeeHub::config();
     $config = $beehubConfig['email'];
     if (!empty($config['host'])) {
         // Configure the transporter for sending through SMTP
         $transport = new Mail\Transport\Smtp();
         $emailConfig = array('host' => $config['host']);
         if (!empty($config['port'])) {
             $emailConfig['port'] = $config['port'];
         }
         if (!empty($config['security'])) {
             $emailConfig['connection_config'] = array();
             $emailConfig['connection_config']['ssl'] = $config['security'];
         }
         if (!empty($config['auth_method'])) {
             $emailConfig['connection_class'] = $config['auth_method'];
             if (!isset($emailConfig['connection_config'])) {
                 $emailConfig['connection_config'] = array();
             }
             $emailConfig['connection_config']['username'] = $config['username'];
             $emailConfig['connection_config']['password'] = $config['password'];
         }
         $options = new Mail\Transport\SmtpOptions($emailConfig);
         $transport->setOptions($options);
     } else {
         // Else we use the Sendmail transporter (which actually just uses mail()
         $transport = new Mail\Transport\Sendmail();
     }
     $this->emailer = $transport;
 }
Esempio n. 9
0
 public function getTransport()
 {
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => $this->smtpHost, 'connection_class' => 'login', 'connection_config' => array('username' => $this->smtpUser, 'password' => $this->smtpPass)));
     $transport->setOptions($options);
     return $transport;
 }
Esempio n. 10
0
 /**
  * @param Message $message
  */
 public function send(Message $message)
 {
     if (!count($message->getFrom())) {
         $message->setFrom('*****@*****.**', 'US Canine Scent Sports');
     }
     $transport = new Transport\Smtp();
     $transport->setOptions($this->transportOptions)->send($message);
 }
Esempio n. 11
0
 /**
  * set SMTP config
  *
  * @param array $config
  * @return $this
  */
 public function setTransport(array $config)
 {
     $transport = new Smtp();
     $options = new SmtpOptions(array('name' => $config['name'], 'host' => $config['host'], 'connection_class' => $config['login'], 'connection_config' => array('username' => $config['user'], 'password' => $config['pass'])));
     $transport->setOptions($options);
     $this->transport = $transport;
     return $this;
 }
Esempio n. 12
0
 public function getServiceConfig()
 {
     return array('factories' => array('mail.transport' => function ($serviceManager) {
         $config = $serviceManager->get('Config');
         $transport = new SmtpTransport();
         $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
         return $transport;
     }));
 }
Esempio n. 13
0
 public function getServiceConfig()
 {
     return array('factories' => array('ZF2Base\\Mail\\Transport' => function ($sm) {
         $config = $sm->get('Config');
         $transport = new SmtpTransport();
         $options = new SmtpOptions($config['mail']);
         $transport->setOptions($options);
         return $transport;
     }));
 }
Esempio n. 14
0
 public function sendMail()
 {
     $message = new Message();
     $message->addTo('*****@*****.**')->addFrom('*****@*****.**')->setSubject('Greetings and Salutations!')->setBody("Sorry, I’m going to be late today!");
     // Setup SMTP transport using LOGIN authentication
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => '127.0.0.1', 'connection_class' => 'login', 'connection_config' => array('username' => 'user', 'password' => 'pass')));
     $transport->setOptions($options);
     $transport->send($message);
 }
Esempio n. 15
0
 public function setSmtp()
 {
     $this->smtp = new Smtp();
     if ($this->checkout == true) {
         $smptOptions = array('host' => $this->config['smtp_host'], 'port' => $this->config['smtp_port'], 'connection_class' => $this->config['smtp_connection_class'], 'connection_config' => array('username' => $this->config['smtp_username'], 'password' => $this->config['smtp_password'], 'ssl' => 'tls'));
         $this->smtp->setOptions(new SmtpOptions($smptOptions));
     } else {
         $this->smtp->setOptions(new SmtpOptions($this->config['transport']['options']));
     }
 }
Esempio n. 16
0
 public function getServiceConfig()
 {
     return array('factories' => array('Mailer' => function ($sm) {
         $config = $sm->get('Config');
         //print_r($config);die;
         $transport = new Smtp();
         $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
         return $transport;
     }));
 }
 /**
  * Prepare SendEmail job
  * 
  * 
  * @uses SendEmailJob
  * 
  * @access public
  * @param ServiceLocatorInterface $serviceLocator
  * @return SendEmailJob
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // Setup SMTP transport using LOGIN authentication
     $config = $serviceLocator->getServiceLocator()->get('Config');
     $options = new SmtpOptions($config['mail_settings']);
     $transport = new Smtp();
     $transport->setOptions($options);
     $job = new SendEmailJob($transport);
     return $job;
 }
Esempio n. 18
0
 public function getServiceConfig()
 {
     return array('factories' => array('Zend\\Authentication\\AuthenticationService' => function ($serviceManager) {
         return $serviceManager->get('doctrine.authenticationservice.orm_default');
     }, 'mail.transport' => function (ServiceManager $serviceManager) {
         $config = $serviceManager->get('Config');
         $transport = new Smtp();
         $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
         return $transport;
     }));
 }
Esempio n. 19
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $logger = $serviceLocator->get('Application\\Logger');
     $transport = new Smtp();
     $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
     $mailer = new Mailer($transport);
     $mailer->setLogger($logger);
     $mailer->setRecipients($config['mailer']['recipients']);
     return $mailer;
 }
Esempio n. 20
0
 /**
  * __construct
  * Método construtor configura o transporte do email
  * @param type $aMailConf
  * @throws Exception\InvalidArgumentException
  */
 public function __construct($aMailConf = array())
 {
     if (count($aMailConf) == 0) {
         $msg = 'Os parâmetros de configuração para email devem ser passados em um array.';
         throw new Exception\InvalidArgumentException($msg);
     }
     $this->aMailConf = $aMailConf;
     //configura a forma de transporte no envio dos emails
     $aMuser = explode('@', $this->aMailConf['mailUser']);
     $domain = $aMuser[1];
     $connConfig = array();
     $connConfig['username'] = $this->aMailConf['mailUser'];
     $connConfig['password'] = $this->aMailConf['mailPass'];
     if ($this->aMailConf['mailProtocol'] != '') {
         $connConfig['ssl'] = $this->aMailConf['mailProtocol'];
     }
     $this->transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => $domain, 'host' => $this->aMailConf['mailSmtp'], 'port' => $this->aMailConf['mailPort'], 'connection_class' => 'plain', 'connection_config' => $connConfig));
     $this->transport->setOptions($options);
 }
Esempio n. 21
0
 public function getServiceConfig()
 {
     return array('factories' => array('SONUser\\Mail\\Transport' => function ($sm) {
         $config = $sm->get('Config');
         $transport = new SmtpTransport();
         $options = new SmtpOptions($config['mail']);
         $transport->setOptions($options);
         return $transport;
     }, 'SONUser\\Service\\User' => function ($sm) {
         return new Service\User($sm->get('Doctrine\\ORM\\EntityManager'), $sm->get('SONUser\\Mail\\Transport'), $sm->get('View'));
     }));
 }
Esempio n. 22
0
 public function sendEmailsFromQueue($developmentMode = false)
 {
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => $this->config['smtp']['name'], 'host' => $this->config['smtp']['host'], 'port' => $this->config['smtp']['port']));
     /** GMAIL SMTP Test
     		$options = new \Zend\Mail\Transport\SmtpOptions();
     
     		$options->setHost('smtp.gmail.com')
                 ->setConnectionClass('login')
                 ->setName('smtp.gmail.com')
                 ->setPort(587)
                 ->setConnectionConfig(array(
                                    'username' => '<email>',
                                    'password' => '<1password > gmail smtp>',
                                    'ssl' => 'tls',
                                  )
                       );
     		*/
     $transport->setOptions($options);
     $entity = new $this->config['database']['entity']();
     $tableName = $this->entityManager->getClassMetadata(get_class($entity))->getTableName();
     $dql = 'SELECT m FROM ' . $this->config['database']['entity'] . ' m WHERE m.send = 0 AND m.scheduleDate < :now ORDER BY m.prio, m.createDate DESC';
     $query = $this->entityManager->createQuery($dql)->setParameter('now', date('Y-m-d H:i:s'))->setMaxResults($this->config['numberOfEmailsPerRun']);
     $queue = $query->getResult();
     foreach ($queue as $mail) {
         // In development mode we only send emails to predefined email addresses to prevent "strange" unrequested
         // emails to users.
         if ($developmentMode === true && !in_array($mail->getRecipientEmail(), $this->config['developmentEmails'])) {
             $this->entityManager->getConnection()->update($tableName, array('send' => 1, 'sendDate' => date('Y-m-d H:i:s')), array('id' => $mail->getId()));
             continue;
         }
         $message = new \Zend\Mail\Message();
         $message->addFrom($mail->getSenderEmail(), $mail->getSenderName())->addTo($mail->getRecipientEmail(), $mail->getRecipientName())->setSubject($mail->getSubject());
         if (trim($mail->getBodyHTML()) !== '') {
             $bodyPart = new \Zend\Mime\Message();
             $bodyMessage = new \Zend\Mime\Part($mail->getBodyHTML());
             $bodyMessage->type = 'text/html';
             $bodyPart->setParts(array($bodyMessage));
             $message->setBody($bodyPart);
             $message->setEncoding('UTF-8');
         } else {
             $message->setBody($mail->getBodyText());
         }
         try {
             $transport->send($message);
             $this->entityManager->getConnection()->update($tableName, array('send' => 1, 'sendDate' => date('Y-m-d H:i:s')), array('id' => $mail->getId()));
         } catch (\Exception $e) {
             $this->entityManager->getConnection()->update($tableName, array('send' => 2, 'error' => $e->getMessage()), array('id' => $mail->getId()));
             $this->queueNewMessage('MailAdmin', $this->config['adminEmail'], $e->getMessage(), $e->getMessage(), 'MailQueue Error', 9);
         }
     }
 }
 public function sendEmailRecoverPassword($senha, $usuario)
 {
     $message = new Message();
     $message->addTo($usuario->getEmail())->addFrom('*****@*****.**')->setSubject('Recuperação de Senha');
     $transport = new SmtpTransport();
     $html = new MimePart('<b>Olá <i>' . $usuario->getNome() . '</i>, uma nova senha foi solicitada no Youselfie. <br> Seguem a baixo suas novas credenciais. <br>' . ' <hr>' . 'E-mail: ' . $usuario->getEmail() . '' . '<br>' . 'Senha: ' . $senha . '</b>');
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->addPart($html);
     $message->setBody($body);
     $transport->setOptions($this->getOptions());
     $transport->send($message);
 }
Esempio n. 24
0
 public function getServiceConfig()
 {
     return array('factories' => array('Anket\\Model\\AnketTable' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $table = new AnketTable($dbAdapter);
         return $table;
     }), 'mail.transport' => function (ServiceManager $serviceManager) {
         $config = $serviceManager->get('Config');
         $transport = new Smtp();
         $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
         return $transport;
     });
 }
 /**
  * @param $config
  * @return SmtpTransport
  */
 private function getTransport($config)
 {
     $config = $this->optionsWithFallback($config);
     switch ($config['transport']) {
         case 'in_memory':
             return new InMemoryTransport();
         case 'smtp':
             $transport = new SmtpTransport();
             $transport->setOptions(new SmtpOptions($config['smtp']));
             return $transport;
     }
     throw new \InvalidArgumentException("Transport of type '{$config['transport']}' not known (use in_memory or smtp)");
 }
Esempio n. 26
0
 /**
  * @param $to
  * @param $from
  * @param $subject
  * @param $text
  */
 public static function send($to, $from, $subject, $text)
 {
     $message = new Message();
     $message->addTo($to)->addFrom($from)->setSubject($subject);
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('host' => MailConstants::HOST, 'connection_class' => 'login', 'connection_config' => array('ssl' => MailConstants::SSL, 'username' => MailConstants::EMAIL, 'password' => MailConstants::PASS), 'port' => MailConstants::PORT));
     $html = new MimePart($text);
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->addPart($html);
     $message->setBody($body);
     $transport->setOptions($options);
     $transport->send($message);
 }
Esempio n. 27
0
 public function send()
 {
     $smtpOptions = new SmtpOptions(array('name' => 'smtp.gmail.com', 'host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'optimus@123', 'port' => 465, 'ssl' => 'TLS')));
     $html = new MimePart($this->getBody());
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->setParts(array($html));
     $mailTransport = new Smtp();
     $mailTransport->setOptions($smtpOptions);
     $mail = new Message();
     $mail->addFrom('*****@*****.**', 'Travelopod')->setEncoding('utf-8')->setTo($this->getTo())->setSubject($this->getSubject())->setBody($body);
     $send = $mailTransport->send($mail);
     $mailTransport->disconnect();
 }
Esempio n. 28
0
 public function getServiceConfig()
 {
     return array('invokables' => ['App\\Auth\\Adapter\\Db' => 'App\\Auth\\Adapter\\Db'], 'factories' => ['authService' => function ($sm) {
         return new \Zend\Authentication\AuthenticationService($sm->get('App\\Auth\\Storage\\Cookie'), $sm->get('App\\Auth\\Adapter\\Db'));
     }, 'App\\Auth\\Storage\\Cookie' => function ($sm) {
         $storage = new \App\Auth\Storage\Cookie();
         $storage->setUserMapper($sm->get('userMapper'));
         return $storage;
     }, 'userDbAuth' => function ($sm) {
         $adapter = new \App\Auth\Adapter\Db();
         $adapter->setUserMapper($sm->get('userMapper'));
         return $adapter;
     }, 'mail' => function ($sm) {
         $config = $sm->get('config');
         $address = $config['mail']['address'];
         $password = $config['mail']['password'];
         // Setup SMTP transport using LOGIN authentication
         $transport = new SmtpTransport();
         $options = new SmtpOptions(['host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => ['ssl' => 'tls', 'username' => $address, 'password' => $password], 'port' => 587]);
         $transport->setOptions($options);
         return $transport;
     }, 'googleApi' => function ($sm) {
         $config = $sm->get('config');
         return new GoogleApi($config['api']['googleapi']);
     }, 'calendar' => function ($sm) {
         $api = $sm->get('googleApi');
         $result = $api->getApiClient();
         if (isset($result['url'])) {
             header('Location: ' . $result['url']);
         }
         return new \Google_Service_Calendar($result['client']);
     }, 'userMapper' => function ($sm) {
         if (is_null(static::$_sm)) {
             static::$_sm = $sm;
         }
         $mapper = static::getMapper('user');
         return $mapper;
     }, 'rdvMapper' => function ($sm) {
         if (is_null(static::$_sm)) {
             static::$_sm = $sm;
         }
         $mapper = static::getMapper('rdv');
         return $mapper;
     }, 'UserTableGateway' => function ($sm) {
         return static::getTableGateway('user');
     }, 'RdvTableGateway' => function ($sm) {
         return static::getTableGateway('rdv');
     }]);
 }
Esempio n. 29
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $sm Service manager
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $sm)
 {
     // Load configurations:
     $config = $sm->get('VuFind\\Config')->get('config');
     // Create mail transport:
     $settings = ['host' => $config->Mail->host, 'port' => $config->Mail->port];
     if (isset($config->Mail->username) && isset($config->Mail->password)) {
         $settings['connection_class'] = 'login';
         $settings['connection_config'] = ['username' => $config->Mail->username, 'password' => $config->Mail->password];
     }
     $transport = new Smtp();
     $transport->setOptions(new SmtpOptions($settings));
     // Create service:
     return new \VuFind\Mailer\Mailer($transport);
 }
Esempio n. 30
0
 public function sendMail()
 {
     $message = new Message();
     $message->addTo('*****@*****.**')->addFrom('*****@*****.**')->setSubject('Test send mail using ZF2');
     // Setup SMTP transport using LOGIN authentication
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => 'scarpa1234'), 'port' => 587));
     $html = new MimePart('<b>heii, <i>sorry</i>, i\'m going late</b>');
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->addPart($html);
     $message->setBody($body);
     $transport->setOptions($options);
     $transport->send($message);
 }