I am using SMTP to send email in my CAKEPHP Project. My email config as follows
class EmailConfig {
public $Smtp = array(
'transport' => 'Smtp',
'from' => array('[email protected]' => 'domainname.com'),
'host' => 'myhostingserver',
'port' => 2525,
'timeout' => 60,
'username' => '[email protected]',
'password' => 'secret',
'client' => null,
'log' => false
);
and my Mail Functionality code as follows
$email = new CakeEmail('Smtp');
$result = $email->template('welcome_mail','default')
->emailFormat('html')
->to($to_email)
->from('[email protected]')
->subject('Welcome to my domain name')
->viewVars($contents);
if($email ->send('Smtp'))
{
echo ('success');
}
While i am sending mail its throwing following error SMTP timeout. My SMTP Server details are correct its working fine in an existing server. I don't know where I am wrong
Check the encryption type (if applicable), e.g. ssl or tls
Your host URL should look something like this in such case
'host' => 'ssl://myhostingserver'
or
'host' => 'tls://myhostingserver'
If your SMTP server has SSL,you have to enable php_openssl
in php.ini
to use this service.
You can use this code to test
if(!in_array('openssl',get_loaded_extensions())){
die('you have to enable php_openssl in php.ini to use this service');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With