Docker 環境で CakePHP 3.5 でアプリケーションを作成しております。
メールの設定は特にしていない(デフォルトのまま)のですが、メールが届いたり届かなかったりします。
特に、夜は届くけれど日中は届かないような感覚があります。
こういうことはあるのでしょうか。
(追記)
届かない場合もエラーにはなっていません。
fromはGmailのアドレスで、toはGoogle Appsのアドレスです。
/var/log/maillogは空っぽでした。
Gmailから受信したメールのソースを見たら、Received: from xxx.localdev ([202.214.xxx.xxx])のようなDockerに設定しているドメインになっていました。
(9/24 追記)
メールの設定
php
1 'EmailTransport' => [ 2 'default' => [ 3 'className' => 'Mail', 4 // The following keys are used in SMTP transports 5 'host' => 'localhost', 6 'port' => 25, 7 'timeout' => 30, 8 'username' => 'user', 9 'password' => 'secret', 10 'client' => null, 11 'tls' => null, 12 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), 13 ], 14 ], 15 16 /** 17 * Email delivery profiles 18 * 19 * Delivery profiles allow you to predefine various properties about email 20 * messages from your application and give the settings a name. This saves 21 * duplication across your application and makes maintenance and development 22 * easier. Each profile accepts a number of keys. See `Cake\Mailer\Email` 23 * for more information. 24 */ 25 'Email' => [ 26 'default' => [ 27 'transport' => 'default', 28 'to' => 'to@example.com', 29 'from' => 'from@gmail.com', 30 'returnPath' => 'from@gmail.com' 31 //'charset' => 'utf-8', 32 //'headerCharset' => 'utf-8', 33 ], 34 ],
メール送信のメソッド
php
1public function register($member) 2{ 3 $this 4 ->setTo($member->email, $member->name) 5 ->setSubject('subject) 6 ->setEmailFormat('text') 7 ->setViewVars(['member' => $member]) 8 ->setTemplate('register'); 9}