Search code examples
phpzend-frameworkzend-db

Zend SMTP default settings


How to initialize Zend Mail SMTP settings and make them available for entire application.

Provided have configured settings in application.ini config file?

Thanks


Solution

  • Add this code in Bootstrap.php file

     protected function _initMailConfig()
    {
        $config = $this->getOptions();
        $host = $config['mail']['smtp']['host'];
        $fromEmail = $config['mail']['from']['email'];
        $fromName = $config['mail']['from']['name'];
        $transport = new Zend_Mail_Transport_Smtp($host);
        Zend_Mail::setDefaultTransport($transport);
        Zend_Mail::setDefaultFrom($fromEmail, $fromName);
    }
    

    also make sure you have predefined settings in application.ini config file

       mail.smtp.host = "smtp-host ip"
       mail.from.email = "your@mail.com"
       mail.from.name = "example"
    

    hope this helps you.