You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If your server has Sendmail installed, update the `config/autoload/mail.local.php.dist` file by setting the `transport` key like below
24
23
25
24
```php
@@ -35,13 +34,16 @@ return [
35
34
]
36
35
```
37
36
38
-
#### Mail - SMTP
37
+
### Mail - SMTP
38
+
39
39
If you want your application to send mails on e.g. registration, contact, then edit the file `config/autoload/mail.local.php`. Set the `transport`, `message_options` and `smtp_options` keys like below.
40
40
41
41
Under `message_options` key:
42
+
42
43
-`from` - email address from whom users will receive emails
43
44
44
45
Under `smtp_options` key:
46
+
45
47
-`host` - the mail server's hostname or IP address
46
48
-`port` - the mail server's port
47
49
-`connection_config` - fill in the `username`, `password` and `ssl` keys with the login details of the email used in `from` above
@@ -113,6 +115,7 @@ try {
113
115
```
114
116
115
117
### Testing if an e-mail message is valid
118
+
116
119
After sending an e-mail you can check if the message was valid or not.
117
120
The `$this->mailService->send()->isValid()` method call will return a boolean value.
118
121
If the returned result is `true`, the e-mail was valid, otherwise the e-mail was invalid.
@@ -121,24 +124,24 @@ In case your e-mail was invalid, you can check for any errors using `$this->mail
121
124
Using the below logic will let you determine if a message was valid or not and log it.
122
125
You can implement your own custom error logging logic.
123
126
124
-
````
127
+
```php
125
128
$result = $this->mailService->send();
126
129
if (! $result->isValid()) {
127
130
//log the error
128
131
error_log($result->getMessage());
129
132
}
130
-
````
131
-
**Note : Invalid e-mail messages will not be sent.**
133
+
```
132
134
135
+
**Note : Invalid e-mail messages will not be sent.**
133
136
134
137
### Logging outgoing emails
138
+
135
139
Optionally, you can keep a log of each successfully sent email. This might be useful when you need to know if/when a specific email has been sent out to a recipient.
136
140
137
141
Logs are stored in the following format: `[YYYY-MM-DD HH:MM:SS]: {"subject":"Test subject","to":["Test Account <test@dotkernel.com>"],"cc":[],"bcc":[]}`.
138
142
139
-
By default, this feature is disabled.
140
-
141
143
In order to enable it, make sure that your `config/autoload/mail.local.php` has the below `log` configuration under the `dot_mail` key:
144
+
142
145
```php
143
146
<?php
144
147
@@ -151,11 +154,15 @@ return [
151
154
]
152
155
];
153
156
```
154
-
To disable it again, set the value of `sent` to `null`.
157
+
158
+
To disable it, set the value of `sent` to `null`.
155
159
156
160
### Saving a copy of an outgoing mail into a folder
157
-
#### Valid only for SMTP Transport
161
+
162
+
### Valid only for SMTP Transport
163
+
158
164
First, make sure the `save_sent_message_folder` key is present in config file `mail.local.php` under `dot_mail.default`. Below you can see its placement and default value.
165
+
159
166
```php
160
167
<?php
161
168
@@ -168,6 +175,7 @@ return [
168
175
],
169
176
];
170
177
```
178
+
171
179
Common folder names are `INBOX`, `INBOX.Archive`, `INBOX.Drafts`, `INBOX.Sent`, `INBOX.Spam`, `INBOX.Trash`. If you have `MailService` available in your class, you can call `$this->mailService->getFolderGlobalNames()` to list the folder global names for the email you are using.
172
180
173
181
Multiple folders can be added to the `save_sent_message_folder` key to save a copy of the outgoing email in each folder.
0 commit comments