PHP code example of ripaclub / zf2-mailman
1. Go to this page and download the library: Download ripaclub/zf2-mailman library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ripaclub / zf2-mailman example snippets
'mailman' => [
'MailMan\Gmail' => [
'default_sender' => '[email protected] ',
'transport' => [
'type' => 'smtp',
'options' => [
'host' => 'smtp.gmail.com',
'port' => '587',
'connection_class' => 'login',
'connection_config' => [
'ssl' => 'tls',
'username' => '[email protected] ',
'password' => 'MYSECRETPASSWORD',
]
]
],
],
],
'modules' => [
// ...
'MailMan',
'Application',
],
$message = new \MailMan\Message();
$message->addTextPart('Test email');
$message->setSubject('My name is methos');
$message->addFrom('[email protected] ', 'Methos');
$message->addTo('[email protected] ', 'RipaClub');
/** @var \MailMan\Service\MailService $mailService */
$mailService = $this->getServiceLocator()->get('MailMan\Gmail');
$mailService->send($message);
$message = new \MailMan\Message();
$message->addAttachment('/path/to/an/attachment.png');
$message->setBody('Test email');
$message->setSubject('My name is methos');
$message->addFrom('[email protected] ', 'Methos');
$message->addTo('[email protected] ', 'RipaClub');
/** @var \MailMan\Service\MailService $mailService */
$mailService = $this->getServiceLocator()->get('MailMan\Gmail');
$mailService->send($message);
$content = new ViewModel();
$content->setTemplate('email/example.phtml');
$content->setVariable('name', 'RipaClub');
$message = new \MailMan\Message();
$message->setSubject('Example email');
$message->addHtmlPart($this->getServiceLocator()->get('ViewRenderer')->render($content));
$message->addTo('[email protected] ', 'RipaClub');
/** @var $mailService \MailMan\Service\MailService */
$mailService = $this->getServiceLocator()->get('MailMan\Gmail');
$mailService->send($message);
<h2>Hi <?= $name;
'mailman' => [
'MailMan\Mandrill' => [
'default_sender' => '[email protected] ',
'transport' => [
'type' => 'mandrill',
'options' => [
'api_key' => 'MYSECRETMANDRILLKEY',
'sub_account' => 'my-optional-subaccount-if-any'
],
],
],
]
'mailman' => [
'MailMan\SMTP' => [
'default_sender' => '[email protected] ',
'transport' => [
'type' => 'smtp',
'options' => [
'host' => 'smtp.gmail.com',
'port' => '587',
'connection_class' => 'login',
'connection_config' => [
'ssl' => 'tls',
'username' => '[email protected] ',
'password' => 'MYSECRETPASSWORD',
]
]
],
],
],
'mailman' => [
'MailMan\Sendmail' => [
'default_sender' => '[email protected] ',
'transport' => [
'type' => 'sendmail'
],
],
],