File: /home/xedaptot/be.naniguide.com/app/Model/SendingServerElasticEmailSmtp.php
<?php
/**
* SendingServerElasticEmailSmtp class.
*
* Abstract class for SendGrid API sending server
*
* LICENSE: This product includes software developed at
* the Acelle Co., Ltd. (http://acellemail.com/).
*
* @category MVC Model
*
* @author N. Pham <[email protected]>
* @author L. Pham <[email protected]>
* @copyright Acelle Co., Ltd
* @license Acelle Co., Ltd
*
* @version 1.0
*
* @link http://acellemail.com
*/
namespace Acelle\Model;
use Acelle\Library\ExtendedSmtpTransport;
use Exception;
class SendingServerElasticEmailSmtp extends SendingServerElasticEmail
{
protected $table = 'sending_servers';
/**
* Send the provided message.
*
* @return bool
*
* @param message
*/
// Inherit class to implementation of this method
public function send($message, $params = array())
{
$this->enableCustomHeaders();
$transport = ExtendedSmtpTransport::newInstance($this->host, (int) $this->smtp_port, $this->smtp_protocol);
$transport->setUsername($this->smtp_username);
$transport->setPassword($this->smtp_password);
$transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false, 'verify_peer_name' => false)));
// Create the Mailer using your created Transport
$mailer = new \Swift_Mailer($transport);
// Actually send
$sent = $mailer->send($message);
if ($sent && $transport->getMessageId()) {
return array(
'runtime_message_id' => $transport->getMessageId(),
'status' => self::DELIVERY_STATUS_SENT,
);
} else {
throw new Exception('Unknown SMTP error');
}
}
}