@@ -17,6 +17,11 @@ class MailBag implements \JsonSerializable
17
17
*/
18
18
private $ from ;
19
19
20
+ /**
21
+ * @var From Reply-To
22
+ */
23
+ private $ replyTo ;
24
+
20
25
/**
21
26
* @var string
22
27
*/
@@ -63,6 +68,15 @@ public function setFrom(string $fromEmail, string $fromName): void
63
68
$ this ->from = new From (new Email ($ fromEmail ), $ fromName );
64
69
}
65
70
71
+ /**
72
+ * @param string $replyToEmail
73
+ * @param string $replyToName
74
+ */
75
+ public function setReplyTo (string $ replyToEmail , string $ replyToName ): void
76
+ {
77
+ $ this ->replyTo = new From (new Email ($ replyToEmail ), $ replyToName );
78
+ }
79
+
66
80
/**
67
81
* @param mixed $subject
68
82
*/
@@ -165,6 +179,22 @@ public function getFromName(): string
165
179
return $ this ->from ->getName ();
166
180
}
167
181
182
+ /**
183
+ * @return string
184
+ */
185
+ public function getReplyToEmail (): string
186
+ {
187
+ return $ this ->replyTo ->getEmail ();
188
+ }
189
+
190
+ /**
191
+ * @return string
192
+ */
193
+ public function getReplyToName (): string
194
+ {
195
+ return $ this ->replyTo ->getName ();
196
+ }
197
+
168
198
/**
169
199
* @return string
170
200
*/
@@ -253,6 +283,7 @@ private function getContent(ContentType $contentType): ?Content
253
283
254
284
return null ;
255
285
}
286
+
256
287
/**
257
288
* @return array
258
289
*/
@@ -302,6 +333,18 @@ function jsonSerialize(): array
302
333
'recipients ' => $ recipients
303
334
];
304
335
336
+ $ replyTo = [];
337
+ if ($ this ->getReplyToEmail ()) {
338
+ $ replyTo ['email ' ] = $ this ->getReplyToEmail ();
339
+ if ($ this ->getReplyToName ()) {
340
+ $ replyTo ['name ' ] = $ this ->getReplyToName ();
341
+ }
342
+ }
343
+
344
+ if ($ replyTo ) {
345
+ $ data ['replyTo ' ] = $ replyTo ;
346
+ }
347
+
305
348
if ($ contents ) {
306
349
$ data ['contents ' ] = $ contents ;
307
350
}
0 commit comments