Skip to content

Commit 0f151d0

Browse files
committed
Use named recipient in from and reply-to
1 parent 36a4548 commit 0f151d0

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

etc/config.sample.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@
4141
}
4242
},
4343
"email": {
44-
"recipient_from": "",
45-
"recipient_reply_to": "",
46-
"smtp_host": "smtp.example.com",
44+
"recipient_from": [
45+
"root@localhost",
46+
"BNETDocs"
47+
],
48+
"recipient_reply_to": [
49+
"root@localhost",
50+
"root"
51+
],
52+
"smtp_host": "localhost",
4753
"smtp_password": "",
48-
"smtp_port": 587,
49-
"smtp_tls": true,
54+
"smtp_port": 25,
55+
"smtp_tls": false,
5056
"smtp_user": ""
5157
},
5258
"memcache": {

src/controllers/User/Register.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,20 @@ protected function tryRegister(Router &$router, UserRegisterModel &$model) {
213213
$mail->Port = $mail_config->smtp_port;
214214

215215
//Recipients
216-
if (!empty($mail_config->recipient_from)) {
217-
$mail->setFrom($mail_config->recipient_from, 'BNETDocs');
216+
if (isset($mail_config->recipient_from[0])) {
217+
$mail->setFrom(
218+
$mail_config->recipient_from[0],
219+
$mail_config->recipient_from[1]
220+
);
218221
}
219222

220223
$mail->addAddress($email, $username);
221224

222-
if (!empty($mail_config->recipient_reply_to)) {
223-
$mail->addReplyTo($mail_config->recipient_reply_to);
225+
if (isset($mail_config->recipient_reply_to[0])) {
226+
$mail->addReplyTo(
227+
$mail_config->recipient_reply_to[0],
228+
$mail_config->recipient_reply_to[1]
229+
);
224230
}
225231

226232
// Content

src/controllers/User/ResetPassword.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,20 @@ protected function doPasswordReset( UserResetPasswordModel &$model, &$data ) {
128128
$mail->Port = $mail_config->smtp_port;
129129

130130
//Recipients
131-
if (!empty($mail_config->recipient_from)) {
132-
$mail->setFrom($mail_config->recipient_from, 'BNETDocs');
131+
if (isset($mail_config->recipient_from[0])) {
132+
$mail->setFrom(
133+
$mail_config->recipient_from[0],
134+
$mail_config->recipient_from[1]
135+
);
133136
}
134137

135138
$mail->addAddress($model->user->getEmail(), $model->user->getName());
136139

137-
if (!empty($mail_config->recipient_reply_to)) {
138-
$mail->addReplyTo($mail_config->recipient_reply_to);
140+
if (isset($mail_config->recipient_reply_to[0])) {
141+
$mail->addReplyTo(
142+
$mail_config->recipient_reply_to[0],
143+
$mail_config->recipient_reply_to[1]
144+
);
139145
}
140146

141147
// Content

0 commit comments

Comments
 (0)