CakePHP Sending Email - LAMPP

2019-07-24 11:09发布

问题:

I am attempting to send an email using Cake's 'Email' component. I have included the component into my controller and I am using the following code to try send an email.

$this->Email->from = 'Glecto <noreply@glecto.com>';
$this->Email->to = 'gary@glecto.com';
$this->Email->replyTo = 'noreply@glecto.com';
$this->Email->subject = 'Let\'s get started!';
$this->Email->delivery = 'mail';
$this->Email->send('Thank you for signing up');

I've also checked my php.ini to ensure the SMTP setting are set up correctly.

Can anyone spot anything wrong that I'm doing here?

回答1:

/* SMTP Options */
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => 'your.smtp.server',
'username'=>'your_smtp_username',
'password'=>'your_smtp_password',
'client' => 'smtp_helo_hostname'
);
/* Set delivery method */
$this->Email->delivery = 'smtp';
/* Do not pass any args to send() */
$this->Email->send();
/* Check for SMTP errors. */
$this->set('smtp_errors', $this->Email->smtpError);