teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

メール設定について追記

2017/09/24 14:53

投稿

phpuser
phpuser

スコア15

title CHANGED
File without changes
body CHANGED
@@ -7,4 +7,56 @@
7
7
  届かない場合もエラーにはなっていません。
8
8
  fromはGmailのアドレスで、toはGoogle Appsのアドレスです。
9
9
  /var/log/maillogは空っぽでした。
10
- Gmailから受信したメールのソースを見たら、Received: from xxx.localdev ([202.214.xxx.xxx])のようなDockerに設定しているドメインになっていました。
10
+ Gmailから受信したメールのソースを見たら、Received: from xxx.localdev ([202.214.xxx.xxx])のようなDockerに設定しているドメインになっていました。
11
+
12
+ (9/24 追記)
13
+ メールの設定
14
+ ```php
15
+ 'EmailTransport' => [
16
+ 'default' => [
17
+ 'className' => 'Mail',
18
+ // The following keys are used in SMTP transports
19
+ 'host' => 'localhost',
20
+ 'port' => 25,
21
+ 'timeout' => 30,
22
+ 'username' => 'user',
23
+ 'password' => 'secret',
24
+ 'client' => null,
25
+ 'tls' => null,
26
+ 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
27
+ ],
28
+ ],
29
+
30
+ /**
31
+ * Email delivery profiles
32
+ *
33
+ * Delivery profiles allow you to predefine various properties about email
34
+ * messages from your application and give the settings a name. This saves
35
+ * duplication across your application and makes maintenance and development
36
+ * easier. Each profile accepts a number of keys. See `Cake\Mailer\Email`
37
+ * for more information.
38
+ */
39
+ 'Email' => [
40
+ 'default' => [
41
+ 'transport' => 'default',
42
+ 'to' => 'to@example.com',
43
+ 'from' => 'from@gmail.com',
44
+ 'returnPath' => 'from@gmail.com'
45
+ //'charset' => 'utf-8',
46
+ //'headerCharset' => 'utf-8',
47
+ ],
48
+ ],
49
+ ```
50
+
51
+ メール送信のメソッド
52
+ ```php
53
+ public function register($member)
54
+ {
55
+ $this
56
+ ->setTo($member->email, $member->name)
57
+ ->setSubject('subject)
58
+ ->setEmailFormat('text')
59
+ ->setViewVars(['member' => $member])
60
+ ->setTemplate('register');
61
+ }
62
+ ```

1

追記しました。

2017/09/24 14:53

投稿

phpuser
phpuser

スコア15

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,10 @@
1
1
  Docker 環境で CakePHP 3.5 でアプリケーションを作成しております。
2
2
  メールの設定は特にしていない(デフォルトのまま)のですが、メールが届いたり届かなかったりします。
3
3
  特に、夜は届くけれど日中は届かないような感覚があります。
4
- こういうことはあるのでしょうか。
4
+ こういうことはあるのでしょうか。
5
+
6
+ (追記)
7
+ 届かない場合もエラーにはなっていません。
8
+ fromはGmailのアドレスで、toはGoogle Appsのアドレスです。
9
+ /var/log/maillogは空っぽでした。
10
+ Gmailから受信したメールのソースを見たら、Received: from xxx.localdev ([202.214.xxx.xxx])のようなDockerに設定しているドメインになっていました。