CakePHP: send mail through SMTP to MS OUTLOOK -> S

2019-05-29 08:22发布

问题:

I figured that I'll try to find out if I can send mails via cmd line before writing a question here. So I followed these steps and sent an e-mail by cmd to myself and a collegue of mine who's working on the same app I am. The message from cmd line came in the format it should have come.

( internal app, should send mails only to my collegues' OUTLOOK accounts )

Everything seems to be connected fine so I figured I have an error in my cakePHP code:

Everything on mails code I have so far is this:

app/config/email.php

public $smtp = array(
    'transport' => 'Smtp',
    'from' => array('from@test.sk'),
    'host' => 'ip_address_of_my_host',
    'port' => 25,
    'timeout' => 30,
    'username' => 'from@test.com',
    'password' => 'password',
    'client' => null,
    'log' => true,
    'charset' => 'utf-8',
    'headerCharset' => 'utf-8',
);

UsersController.php (test send mail function)

    public function test_send_email() {
        $this->autoRender = false;
        App::uses('CakeEmail', 'Network/Email');
        $email = new CakeEmail('smtp');
        $email->from(array('from@test.com' => 'APP TEST'));
        $email->to('me@test.com');
        $email->subject('Subject of testing');
        $email->send('Message of testing');
    }

After 5 seconds of loading I get: SMTP Error: 504 5.7.4 Unrecognized authentication type

回答1:

Solved:

I guess the authentication wasnt required on EXCHANGE, so I just removed the password parameter and works fine.

During research I found out this article, so the next step would be to contact EXCHANGE admins.

http://blogs.technet.com/b/exchange/archive/2006/12/28/3397620.aspx



回答2:

I was getting the same error when using telnet on port 25. After changing to port 587, I was able to use authenticated SMTP.