简体   繁体   中英

CakePHP 2.0 Email SMTP Error

I'm getting this error when I try to mail from CakePHP 2.0 using CakeEmail:

SMTP Error: 502 5.5.1 Unrecognized command. p1si477061pbk.249

I'm sending from Gmail, and here is my config:

public $gmail = array(
    'transport' => 'Smtp',
    'host' => 'aspmx.l.google.com',
    'port' => 25,
    'timeout' => 30,
    'username' => 'user',
    'password' => 'secret',
    'client' => null,
    'log' => true
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);

The host and port came from this article here: http://www.google.com/support/a/bin/answer.py?answer=176600

You have to use SSL option in your code.

/* SMTP Options */
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'your_username@gmail.com',
'password'=>'your_gmail_password',
);

/* Set delivery method */
$this->Email->delivery = 'smtp';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM