9
9
10
10
use Laminas \Mail \Exception \InvalidArgumentException as LaminasInvalidArgumentException ;
11
11
use Magento \Framework \App \ObjectManager ;
12
- use Magento \Framework \Exception \LocalizedException ;
13
12
use Magento \Framework \Mail \Exception \InvalidArgumentException ;
14
13
use Laminas \Mail \Address as LaminasAddress ;
15
14
use Laminas \Mail \AddressList ;
@@ -52,7 +51,6 @@ class EmailMessage extends Message implements EmailMessageInterface
52
51
* @param string|null $encoding
53
52
* @param LoggerInterface|null $logger
54
53
* @throws InvalidArgumentException
55
- * @throws LocalizedException
56
54
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
57
55
* @SuppressWarnings(PHPMD.NPathComplexity)
58
56
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -126,7 +124,7 @@ public function getHeaders(): array
126
124
/**
127
125
* @inheritDoc
128
126
*
129
- * @throws LocalizedException
127
+ * @throws InvalidArgumentException
130
128
*/
131
129
public function getFrom (): ?array
132
130
{
@@ -136,7 +134,7 @@ public function getFrom(): ?array
136
134
/**
137
135
* @inheritDoc
138
136
*
139
- * @throws LocalizedException
137
+ * @throws InvalidArgumentException
140
138
*/
141
139
public function getTo (): array
142
140
{
@@ -146,7 +144,7 @@ public function getTo(): array
146
144
/**
147
145
* @inheritDoc
148
146
*
149
- * @throws LocalizedException
147
+ * @throws InvalidArgumentException
150
148
*/
151
149
public function getCc (): ?array
152
150
{
@@ -156,7 +154,7 @@ public function getCc(): ?array
156
154
/**
157
155
* @inheritDoc
158
156
*
159
- * @throws LocalizedException
157
+ * @throws InvalidArgumentException
160
158
*/
161
159
public function getBcc (): ?array
162
160
{
@@ -166,7 +164,7 @@ public function getBcc(): ?array
166
164
/**
167
165
* @inheritDoc
168
166
*
169
- * @throws LocalizedException
167
+ * @throws InvalidArgumentException
170
168
*/
171
169
public function getReplyTo (): ?array
172
170
{
@@ -222,7 +220,7 @@ public function toString(): string
222
220
*
223
221
* @param AddressList $addressList
224
222
* @return Address[]
225
- * @throws LocalizedException
223
+ * @throws InvalidArgumentException
226
224
*/
227
225
private function convertAddressListToAddressArray (AddressList $ addressList ): array
228
226
{
@@ -245,7 +243,7 @@ private function convertAddressListToAddressArray(AddressList $addressList): arr
245
243
*
246
244
* @param Address[] $arrayList
247
245
* @return AddressList
248
- * @throws LaminasInvalidArgumentException|LocalizedException
246
+ * @throws LaminasInvalidArgumentException|InvalidArgumentException
249
247
*/
250
248
private function convertAddressArrayToAddressList (array $ arrayList ): AddressList
251
249
{
@@ -273,15 +271,14 @@ private function convertAddressArrayToAddressList(array $arrayList): AddressList
273
271
*
274
272
* @param ?string $email
275
273
* @return ?string
276
- * @throws LocalizedException
274
+ * @throws InvalidArgumentException
277
275
*/
278
276
private function sanitiseEmail (?string $ email ): ?string
279
277
{
280
278
if (!empty ($ email ) && str_starts_with ($ email , '=? ' )) {
281
279
$ decodedValue = iconv_mime_decode ($ email , ICONV_MIME_DECODE_CONTINUE_ON_ERROR , 'UTF-8 ' );
282
- $ localPart = explode ('@ ' , $ decodedValue );
283
- if (isset ($ localPart [0 ]) && str_contains ($ localPart [0 ], ' ' )) {
284
- throw new LocalizedException (__ ('Invalid email format ' ));
280
+ if (str_contains ($ decodedValue , ' ' )) {
281
+ throw new InvalidArgumentException ('Invalid email format ' );
285
282
}
286
283
}
287
284
0 commit comments