Skip to content

Simple Java Mail Wishlist -- clearRecipients() #90

Closed

Description

@dormitionskete

I recently became acquainted with SimpleJavaMail. I've been testing it for a few days, and so far, I like it very much. Thank you very much for making it, and sharing it with us!

On your website, you asked for suggestions for how it could be improved. I have a few "wishlist" items for it. I'll put them in separate tickets so you can evaluate and track them individually.


Please add a way to clear the recipient list so the email object can be reused without having to reset all of the other fields:

email.clearRecipients();

If this was implemented, we could create the email once, add some recipients, send it, clear the recipients, add more recipients, send it again, etc. That would be very useful for bulk mailings where you don't want a lot of recipients, lest it be considered spam.

Activity

  1. bbottema commented on Aug 14, 2017

    @bbottema
    Owner

    I'm on the fence on this one. If you add clearRecipients() why not 'clearHTMLBody()' or 'clearSubject()', clearAttachments().

    Moreover, if you use the EmailBuilder, you can configure it once without recipients, then use it multiple times to build the same email:

    EmailBuilder emailBuilder = new EmailBuilder()
        .from("sender", "sender@domain.com")
        .subject("your subject")
        (..);
    
    Email email1 = emailBuilder.build();
    Email email2 = emailBuilder.build();
    
  2. dormitionskete commented on Aug 14, 2017

    @dormitionskete
    Author

    Ok. That would work. Thank you! That didn't occur to me.

    We send out weekly newsletters, sending the same message, but sending it out as a separate email to each "AddressData" record in the group. Each of these records can have up to two email addresses, and in those cases, it's sent to both as one email. And it works well for us. In the past, when we sent them BCC to over 100 recipients, it'd be treated as spam by some people's servers / email clients. Since we started sending them this way, that has not been a problem.

    I was thinking it'd be nice to create the Email object once, clear the recipients each time, etc. But creating an EmailBuilder object, and reusing it would accomplish the same thing.

    Thank you again for your time and attention to this matter!

    And thanks again for sharing this great project. I appreciate it.

  3. bbottema commented on Aug 14, 2017

    @bbottema
    Owner

    With your use case, I just realized that there's a bug with the EmailBuilder: #94. Currently this is blocking reuse of a single builder.

    I'll get that fixed asap. Until then I will keep this issue open.

  4. dormitionskete commented on Aug 14, 2017

    @dormitionskete
    Author

    Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions