@@ -395,6 +395,10 @@ public boolean validate(final Email email)
395
395
throw new MailerException (MailerException .MISSING_RECIPIENT );
396
396
} else if (email .getFromRecipient () == null ) {
397
397
throw new MailerException (MailerException .MISSING_SENDER );
398
+ } else if (email .isUseDispositionNotificationTo () && email .getDispositionNotificationTo () == null ) {
399
+ throw new MailerException (MailerException .MISSING_DISPOSITIONNOTIFICATIONTO );
400
+ } else if (email .isUseReturnReceiptTo () && email .getReturnReceiptTo () == null ) {
401
+ throw new MailerException (MailerException .MISSING_RETURNRECEIPTTO );
398
402
} else if (emailAddressCriteria != null ) {
399
403
if (!EmailAddressValidator .isValid (email .getFromRecipient ().getAddress (), emailAddressCriteria )) {
400
404
throw new MailerException (format (MailerException .INVALID_SENDER , email ));
@@ -408,11 +412,13 @@ public boolean validate(final Email email)
408
412
.isValid (email .getReplyToRecipient ().getAddress (), emailAddressCriteria )) {
409
413
throw new MailerException (format (MailerException .INVALID_REPLYTO , email ));
410
414
}
411
- if (email .isUseDispositionNotificationTo () && email .getDispositionNotificationTo () == null ) {
412
- throw new MailerException (MailerException .MISSING_DISPOSITIONNOTIFICATIONTO );
415
+ if (email .isUseDispositionNotificationTo () && !EmailAddressValidator
416
+ .isValid (email .getDispositionNotificationTo ().getAddress (), emailAddressCriteria )) {
417
+ throw new MailerException (format (MailerException .INVALID_DISPOSITIONNOTIFICATIONTO , email ));
413
418
}
414
- if (email .isUseReturnReceiptTo () && email .getReturnReceiptTo () == null ) {
415
- throw new MailerException (MailerException .MISSING_RETURNRECEIPTTO );
419
+ if (email .isUseReturnReceiptTo () && !EmailAddressValidator
420
+ .isValid (email .getReturnReceiptTo ().getAddress (), emailAddressCriteria )) {
421
+ throw new MailerException (format (MailerException .INVALID_RETURNRECEIPTTO , email ));
416
422
}
417
423
}
418
424
return true ;
0 commit comments