Sending Mails by running Shell Script

I want to send email from my local system to gmail account using shell script.

Here is the code of the files email.php and TestingShell.php


<?php class EmailConfig { public $gmail = array( 'host' => 'ssl://', 'port' => 465, 'username' => '', 'password' => 'mypassword', 'transport' => 'Smtp' ); } ?>


<?php App::uses('CakeEmail', 'Network/Email'); class TestingShell extends AppShell { public function main(){ $Email = new CakeEmail('gmail'); $Email->from(array('' => 'myName')) ->to('') ->subject('Test:Sending Email') ->emailFormat('both') ->template('testing', 'default') ->send(); $this->out('Successfully sent email ', 1, Shell::NORMAL); } } ?>

When I try running the shell script file from my CommandPrompt it gives me the error as “SMTP Timeout” and the mail is not sent.

Any help on this will be appreciated

‘tls’ => false,
‘host’ => ‘ssl://’

If you are using Windows, use this for testing (server would be localhost, etc.):

1 Like

Thanks. The Test mail server tool worked for me.