dev-master
9999999-dev http://www.canarium.phSends Email using a Google Account defined in the configuration
MIT
canarium una realidad
Sends Email using a Google Account defined in the configuration
Sends Email using a Google Account defined in the configuration., (*1)
Create a file goaliomailservice.local.php
in you appinstance's config/autoload/
directory., (*2)
Paste the following in the file:, (*3)
$google_username = ''; $google_password = ''; /** * You do not need to edit below this line */ return array( 'goaliomailservice' => array( 'transport_class' => 'Zend\Mail\Transport\Smtp', 'options_class' => 'Zend\Mail\Transport\SmtpOptions', 'options' => array( 'host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => array( 'ssl' => 'tls', 'username' => $google_username, 'password' => $google_password ), 'port' => 587 ) ) );
Add the value for $google_username
and $google_password
with the credentials from your google account. Take note that this is a local file and will not be commited to the repository., (*4)
That is all you need to send email in canarium., (*5)
Once initialized, the service goaliomailservice_message
will be available for you to retrive via Service Manager. Example:, (*6)
$mailService = $this->getServiceLocator()->get('goaliomailservice_message');
Now send an email, (*7)
$message = $mailService->createHtmlMessage( $$from_email, $to_email, $subject, 'index/email', $params ); $mailService->send($message);
Return a HTML message ready to be sent, (*8)
public function createHtmlMessage($from, $to, $subject, $nameOrModel, $values = array()):MailMessage;
Parameter | Description |
---|---|
$from | A string containing the sender e-mail address, or if array with keys email and name |
$to | An array containing the recipients of the mail |
$subject | Subject of the mail |
$nameOrModel | Either the template to use, or a ViewModel |
$values | Values to use when the template is rendered. The variables passed will be assessible to the template specified in $nameOrModel |
Return a text message ready to be sent, (*9)
public function createTextMessage($from, $to, $subject, $nameOrModel, $values = array()):MailMessage;
Parameter | Description |
---|---|
$from | A string containing the sender e-mail address, or if array with keys email and name |
$to | An array containing the recipients of the mail |
$subject | Subject of the mail |
$nameOrModel | Either the template to use, or a ViewModel |
$values | Values to use when the template is rendered. The variables passed will be assessible to the template specified in $nameOrModel |
Sends the MailMessage, (*10)
public function send(MailMessage $message)
Sends Email using a Google Account defined in the configuration
MIT
canarium una realidad