Skip to content

Commit 6285abe

Browse files
committed
#101: keep the old addRecipient API as deprecated to give library users time to migrate
1 parent 19acd26 commit 6285abe

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/main/java/org/simplejavamail/email/Email.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,66 @@ public void addRecipients(@Nonnull final Recipient... recipientsToAdd) {
411411
recipients.add(new Recipient(recipient.getName(), address, type));
412412
}
413413
}
414+
415+
/**
416+
* Adds a new {@link Recipient} to the list on account of name, address and recipient type (eg. {@link RecipientType#CC}).
417+
* <p>
418+
* The address string can be a comma/semicolon separated list and addresses can also be of the format {@code "name <address>"}.
419+
*
420+
* @param name The name of the recipient.
421+
* @param address The emailadres of the recipient or delimited list of addresses, optionally with overriding names.
422+
* @param type The type of receiver (eg. {@link RecipientType#CC}).
423+
* @see #recipients
424+
* @see Recipient
425+
* @see RecipientType
426+
* @deprecated Due to the increasing complexity of address combinations, in v5.0.0 this method will be removed in favor of
427+
* {@link #addNamedToRecipients(String, String...)},
428+
* {@link #addNamedCcRecipients(String, String...)} and {@link #addNamedBccRecipients(String, String...)}.
429+
*/
430+
@Deprecated
431+
public void addRecipient(@Nullable final String name, @Nonnull final String address, @Nonnull final RecipientType type) {
432+
checkNonEmptyArgument(address, "address");
433+
checkNonEmptyArgument(type, "type");
434+
addRecipients(name, type, address);
435+
}
436+
437+
/**
438+
* Adds a new {@link Recipient} to the list on account of name, address and recipient type (eg. {@link RecipientType#CC}).
439+
* <p>
440+
* The address string can be a comma/semicolon separated list and addresses can also be of the format {@code "name <address>"}.
441+
*
442+
* @param emailAddressList The emailadres of the recipient or delimited list of addresses, optionally with overriding names.
443+
* @param type The type of receiver (eg. {@link RecipientType#CC}).
444+
* @see #recipients
445+
* @see Recipient
446+
* @see RecipientType
447+
* @deprecated Due to the increasing complexity of address combinations, in v5.0.0 this method will be removed in favor of
448+
* {@link #addToRecipients(String...)}, {@link #addCcRecipients(String...)} and {@link #addBccRecipients(String...)}.
449+
*/
450+
@Deprecated
451+
public void addRecipients(@Nonnull final String emailAddressList, @Nonnull final RecipientType type) {
452+
checkNonEmptyArgument(type, "type");
453+
checkNonEmptyArgument(emailAddressList, "emailAddressList");
454+
addRecipients(null, type, emailAddressList);
455+
}
456+
457+
/**
458+
* Adds all given recipients addresses to the list on account of address and recipient type (eg. {@link RecipientType#CC}).
459+
* <p>
460+
* The address strings can be a comma/semicolon separated lists, and addresses can also be of the format {@code "name <address>"}.
461+
*
462+
* @param recipientEmailAddressesToAdd The emailadresses of the recipients or delimited lists of addresses, optionally with overriding names.
463+
* @see #recipients
464+
* @see Recipient
465+
* @see RecipientType
466+
* @deprecated Due to the increasing complexity of address combinations, in v5.0.0 this method will be removed in favor of
467+
* {@link #addToRecipients(String...)}, {@link #addCcRecipients(String...)} and {@link #addBccRecipients(String...)}.
468+
*/
469+
@Deprecated
470+
public void addRecipients(@Nonnull final RecipientType type, @Nonnull final String... recipientEmailAddressesToAdd) {
471+
checkNonEmptyArgument(type, "type");
472+
addRecipients(null, type, recipientEmailAddressesToAdd);
473+
}
414474

415475
/**
416476
* Adds an embedded image (attachment type) to the email message and generates the necessary {@link DataSource} with the given byte data. Then

0 commit comments

Comments
 (0)