簡體   English   中英

從SMTP遠程服務器CakePHP 3發送電子郵件

[英]Send Email from SMTP remote server CakePHP 3

我在配置我的應用程序以從我的smtp服務器發送郵件時遇到一些問題,該服務器位於一個帶有1and1的遠程主機中。 我不知道我是否遺漏了一些東西:

  • 我已將app.php更改為托管服務提供商提供的值:

     'EmailTransport' => [ 'default' => [ 'className' => 'Mail', 'host' => 'smtp.1and1.com', 'port' =>'587' , 'timeout' => 30, 'username' => 'me@dns.com', 'password' => '******', 'client' => null, 'tls' => null, ], ], 'Email' => [ 'default' => [ 'transport' => 'default', 'from' => '@localhost', //'charset' => 'utf-8', //'headerCharset' => 'utf-8', ], ], 

在這里,您可以看到我的托管服務提供商提供的連接到他們的smtp服務器的說明。

smtp requiere comfig

我沒有得到任何結果。 有沒有人有一個想法,我可能會失蹤?

我得到它的工作設置classname為'Mail',其余的參數默認。 請按以下方式行事:

'EmailTransport' => [
        'default' => [
            'className' => 'Mail',
            // The following keys are used in SMTP transports
            'host' => 'localhost',
            'port' => 25,
            'timeout' => 30,
            'username' => 'user',
            'password' => 'secret',
            'client' => null,

        ],
    ],

在我的情況下,只有className中的問題。

對於使用gmail或office365服務器,它應該是這樣的:

'EmailTransport' => [
        'default' => [
            'className' => 'Mail',
            // The following keys are used in SMTP transports
            'host' => 'smtp.office365.com',
            'port' => 587,
            'timeout' => 30,
            'username' => 'my@email.com',
            'password' => 'myPassword',
            'client' => null,
            'tls' => true,
            'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
        ],
    ],

請執行以下操作:

//Adding Smtp information for sending mail through smtp instead of php mail function on local server / live server

'EmailTransport' => [
    'default' => [
        'className' => 'Smtp',
        'host' => 'smtp.1and1.com',
        'port' =>'587' ,
        'timeout' => 30,
        'username' => 'me@dns.com',
        'password' => '******',
        'client' => null,
        'tls' => null,
    ],
],

如果需要,您還可以啟用tls到'tls' => true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM