Class DraftEmail
java.lang.Object
de.gustavblass.commons.email.DraftEmail
-
Field Summary
FieldsModifier and TypeFieldDescriptionAny number of files to send along with the message.private @NonNull Set<jakarta.mail.internet.InternetAddress> Whom the e-mail shall be blind-carbon-copied to.private @NonNull Set<jakarta.mail.internet.InternetAddress> Whom the e-mail shall be carbon-copied to.private booleanIf the e-mail could not be encrypted, should it be sent unencrypted?private static final org.apache.logging.log4j.Loggerprivate @NonNull StringThe actual content of the e-mail.private @NonNull Set<jakarta.mail.internet.InternetAddress> Whom the e-mail shall be sent to.private booleanWhether the e-mail should be stored in the “sent” folder of the user's inbox.private @NonNull StringWhat the e-mail is about. -
Constructor Summary
ConstructorsConstructorDescriptionDraftEmail(@NonNull String subject, @NonNull String message, @NonNull Set<jakarta.mail.internet.InternetAddress> recipients) Creates a new draft e-mail.DraftEmail(@NonNull String subject, @NonNull String message, @NonNull Set<jakarta.mail.internet.InternetAddress> recipients, @NonNull Set<File> attachments) Creates a new draft e-mail. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachments(@NonNull Set<File> attachments) Appends the given files to the already specified ones.voidaddBccRecipients(@NonNull Set<jakarta.mail.internet.InternetAddress> bccRecipients) Appends the given recipients to the already specified ones.voidaddCcRecipients(@NonNull Set<jakarta.mail.internet.InternetAddress> ccRecipients) Appends the given recipients to the already specified ones.voidaddPublicKeys(@NonNull Set<String> publicKeys) Appends the given keys to the already specified ones.voidaddRecipients(@NonNull Set<jakarta.mail.internet.InternetAddress> recipients) Appends the given recipients to the already specified ones.Returns theattachmentsof the e-mail.@NonNull Set<jakarta.mail.internet.InternetAddress> Returns thebccRecipientsof the e-mail.@NonNull Set<jakarta.mail.internet.InternetAddress> Returns theccRecipientsof the e-mail.Returns thepublicKeysof the e-mail.@NonNull Set<jakarta.mail.internet.InternetAddress> Returns therecipientsof the e-mail.voidDeletes allattachments.voidDeletes allbccRecipients.voidDeletes allccRecipients.voidDeletes allpublicKeys.voidreplaceAttachments(@NonNull Set<File> attachments) Deletes allattachmentsand adds the given ones instead.voidreplaceBccRecipients(@NonNull Set<jakarta.mail.internet.InternetAddress> bccRecipients) Deletes allbccRecipientsand adds the given ones instead.voidreplaceCcRecipients(@NonNull Set<jakarta.mail.internet.InternetAddress> ccRecipients) Deletes allccRecipientsand adds the given ones instead.voidreplacePublicKeys(@NonNull Set<String> publicKeys) Deletes allpublicKeysand adds the given ones instead.voidreplaceRecipients(@NonNull Set<jakarta.mail.internet.InternetAddress> recipients) Deletes allrecipientsand adds the given ones instead.voidsetMessage(@NonNull String message) Updates the actual content of the e-mail.voidsetSubject(@NonNull String subject) Updates thesubjectof the e-mail.
-
Field Details
-
LOG
private static final org.apache.logging.log4j.Logger LOG -
subject
What the e-mail is about. Will be shown in the subject line of the e-mail client. -
message
The actual content of the e-mail. -
recipients
Whom the e-mail shall be sent to. -
ccRecipients
Whom the e-mail shall be carbon-copied to. -
bccRecipients
Whom the e-mail shall be blind-carbon-copied to. -
attachments
-
publicKeys
-
fallBackToUnencrypted
private boolean fallBackToUnencryptedIf the e-mail could not be encrypted, should it be sent unencrypted? -
saveToSentFolder
private boolean saveToSentFolderWhether the e-mail should be stored in the “sent” folder of the user's inbox.
-
-
Constructor Details
-
DraftEmail
public DraftEmail(@NonNull @NonNull String subject, @NonNull @NonNull String message, @NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> recipients) throws de.gustavblass.commons.exceptions.IllegalArgumentException Creates a new draft e-mail.- Parameters:
subject- Thesubjectof the e-mail.message- The actual content of the e-mail.recipients- Therecipientsof the e-mail. At least one e-mail address must be specified.- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If no recipient is set.
-
DraftEmail
public DraftEmail(@NonNull @NonNull String subject, @NonNull @NonNull String message, @NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> recipients, @NonNull @NonNull Set<File> attachments) throws de.gustavblass.commons.exceptions.IllegalArgumentException Creates a new draft e-mail.- Parameters:
subject- Thesubjectof the e-mail.message- The actual content of the e-mail.recipients- Therecipientsof the e-mail. At least one e-mail address must be specified.attachments- Any number of files to send along with the message.- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If no recipient is set.
-
-
Method Details
-
setSubject
-
setMessage
Updates the actual content of the e-mail.- Parameters:
message- The new content of the e-mail.
-
replaceRecipients
public void replaceRecipients(@NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> recipients) throws de.gustavblass.commons.exceptions.IllegalArgumentException Deletes allrecipientsand adds the given ones instead.- Parameters:
recipients- The new e-mail addresses which the e-mail shall be sent to. Must contain at least one address.- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If the given set is empty.
-
addRecipients
public void addRecipients(@NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> recipients) throws de.gustavblass.commons.exceptions.IllegalArgumentException Appends the given recipients to the already specified ones.- Parameters:
recipients- The new e-mail addresses which the e-mail shall be sent to. Must contain at least one address.- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If the given set is empty.
-
replaceCcRecipients
public void replaceCcRecipients(@NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> ccRecipients) Deletes allccRecipientsand adds the given ones instead.- Parameters:
ccRecipients- The new e-mail addresses which the e-mail shall be carbon-copied to. If no address is set, the e-mail will not be carbon-copied to anyone.
-
addCcRecipients
public void addCcRecipients(@NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> ccRecipients) Appends the given recipients to the already specified ones.- Parameters:
ccRecipients- The new e-mail addresses which the e-mail shall be carbon-copied to. If no address is set, the e-mail will still be carbon-copied to the already specified ones.
-
removeCcRecipients
public void removeCcRecipients()Deletes allccRecipients. The e-mail will not be carbon-copied to anyone. -
replaceBccRecipients
public void replaceBccRecipients(@NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> bccRecipients) Deletes allbccRecipientsand adds the given ones instead.- Parameters:
bccRecipients- The new e-mail addresses which the e-mail shall be blind-carbon-copied to. If no address is set, the e-mail will not be blind-carbon-copied to anyone.
-
addBccRecipients
public void addBccRecipients(@NonNull @NonNull Set<jakarta.mail.internet.InternetAddress> bccRecipients) Appends the given recipients to the already specified ones.- Parameters:
bccRecipients- The new e-mail addresses which the e-mail shall be blind-carbon-copied to. If no address is set, the e-mail will still be blind-carbon-copied to the already specified ones.
-
removeBccRecipients
public void removeBccRecipients()Deletes allbccRecipients. The e-mail will not be blind-carbon-copied to anyone. -
replaceAttachments
Deletes allattachmentsand adds the given ones instead.- Parameters:
attachments- The new files which the e-mail shall be sent with. If no file is set, the e-mail will not be sent with any files.
-
addAttachments
Appends the given files to the already specified ones.- Parameters:
attachments- The new files which the e-mail shall be sent with. If no file is set, the e-mail will still be sent with the already specified ones.
-
removeAttachments
public void removeAttachments()Deletes allattachments. The e-mail will not be sent with any files. -
replacePublicKeys
Deletes allpublicKeysand adds the given ones instead.- Parameters:
publicKeys- The new PGP public keys which the e-mail shall be encrypted with. If no key is set, the e-mail will not be encrypted.
-
addPublicKeys
Appends the given keys to the already specified ones.- Parameters:
publicKeys- The new PGP public keys which the e-mail shall be encrypted with. If no key is set, the e-mail will still be encrypted with the already specified ones.
-
removePublicKeys
public void removePublicKeys()Deletes allpublicKeys. The e-mail will not be encrypted. -
getRecipients
Returns therecipientsof the e-mail.- Returns:
- Whom the e-mail shall be sent to.
-
getCcRecipients
Returns theccRecipientsof the e-mail.- Returns:
- Whom the e-mail shall be carbon-copied to.
-
getBccRecipients
Returns thebccRecipientsof the e-mail.- Returns:
- Whom the e-mail shall be blind-carbon-copied to.
-
getAttachments
Returns theattachmentsof the e-mail.- Returns:
- Any number of files to send along with the message.
-
getPublicKeys
Returns thepublicKeysof the e-mail.- Returns:
- Any number of PGP public keys to encrypt the message with.
-