arvind2110/zf2mail

There is no license information available for the latest version (dev-master) of this package.

ZF2-Mail is very simple ZF2 module for handling ZF2 mails.

dev-master 2014-06-24 09:20 UTC

This package is not auto-updated.

Last update: 2024-05-20 23:56:18 UTC


README

ZF2-Mail is a simple ZF2 module to implement and manage mail functionality in ZF2 applications.

SMTP settings : module.config.php

return array(
    "EMAIL" => array(
        "SMTP_SENDER_TYPE" => "user",
        "SMTP_NAME" => "localhost",
        "SMTP_HOST" => "localhost",
        "SMTP_PORT" => "25",
        "SMTP_CONNECTION_CLASS" => "plain",
        "SMTP_USERNAME" => "",
        "SMTP_PASSWORD" => "",
        "SMTP_SSL" => "",
        "BODY" => "Custom default message",
        "FROM" => "noreply@example.com",
        "TO" => "yoremail@example.com",
        "MAIL_FROM_NICK_NAME" => "Custom Name",
        "SUBJECT" => "Custom Subject",
        "FROM_NICK_NAME" => "Cutom From",
        "EMAIL_TEMPLATE_PATH" => __DIR__ . "/../view/emails/templates/",
        "USE_SMTP" => FALSE
    )    
);

Sending Mails

$mail = $this->getServiceLocator()->get('ZF2Mail');
        
$mailOptions = array(
    'mailTo' => 'arvind.singh.2110@gmail.com',
    'mailFrom' => 'example@example.com',
    'mailSubject' => 'My Custom Subject',
    'mailBody' => 'My custom message',
    'templateFile' => 'custom-message',
    'params' => array('name' => 'Arvind Singh')
);
$mail->sendMail($mailOptions);

You can pass other parameters as per your requirement.