[seam-dev] Is this the mail API you always wanted?

Lincoln Baxter, III lincolnbaxter at gmail.com
Mon Feb 7 14:41:08 EST 2011


Also,

https://github.com/seam/mail/blob/master/api-base/src/main/java/org/jboss/seam/mail/core/EmailAttachment.java

Should EmailAttachment perhaps be an interface? Encouraging again the idea
that email attachments can come from anywhere as long as the data can be
properly read and streamed into the Message itself? (Considered using
InputStreams instead of byte[] arrays?)

~Lincoln

On Mon, Feb 7, 2011 at 2:36 PM, Emmanuel Bernard <emmanuel at hibernate.org>wrote:

> Random comments:
>  - Is the from() method overloaded with a one arg version? We don't always
> have a decent name to associate an email with.
>  - does it make sense to support varargs for to(): to("
> emmanuel at nothingtosee.org", "dan at test.com")
>  - Make sure this API can also easily be used by people working in batches:
> ie pass a collection of to(Collection<String>) emails ie
>  .bcc((setOfEmails);
>  - can the builder API be made contextual: ie if I start with a template()
> then bodyText() is not available (probably not going to be easy)
>  - is there an overloaded method send() with no arg (does that make sense?)
>  - does it make sense to have a typesafe template parameter injection
>
> message
>   .template(ThankYouTemplate.class)
>     .date( new Date() )
>     .amount( amountInEur )
>   .send()
>
> Where ThankYouTemplate is something like
>
> @Template(file="my.template.vm", type=HTML)
> interface ThankYouTemplate extends EmailTemplate< ThankYouTemplate> {
>   ThankYouTemplate date(Date date);
>   ThankYouTemplate amount(BigDecimal amount);
> }
>
> This idea is an important departure from what has been done but might be
> worth prototyping. We have done stuffs vaguely similar in Hibernate
> Validator for the programmatic configuration API (constraints expose their
> parameters in a type-safe way.
>
> http://docs.jboss.org/hibernate/validator/4.2/reference/en-US/html_single/#programmaticapi
>
> Emmanuel
>
>
> On 7 févr. 2011, at 19:57, Dan Allen wrote:
>
> Seam devs,
>
> Cody is looking for some feedback on the mail module [1] before he drafts a
> reference guide and puts the API on ice.
>
> Seam mail is important because, let's face it, the Java Mail API needs a
> makeover. Thankfully, the CDI programming model offers the necessary hooks
> to create a modernized mail API capable of deep integration with the Java EE
> platform (specifically the Java Mail API and container-managed sessions).
>
> Seam Mail offers a fluent API that makes sending e-mail in Java a painless
> experience. But an e-mail is nothing without the content. That's why Seam
> Mail offers several templating options, such as Velocity, as well as an
> extensible template SPI, to allow you to select your templating solution of
> choice. With Seam Mail, you'll be sending e-mail from your application in no
> time.
>
> Is this how you imagined it would be?
>
> Basic:
>
>    @Inject
>    private Instance<MailMessage> mailMessage;
>
>    @Inject
>    private Session session;
>
>    mailMessage.get()
>          .from("Seam Framework", "seam at jboss.org")
>          .to("John Smith", "john.smith at acme.com")
>          .subject("Text Message from Seam Mail - " +
> java.util.UUID.randomUUID().toString())
>          .textBody(text)
>          .send(session);
>
> Velocity:
>
>    @Inject
>    private Instance<VelocityMailMessage> velocityMailMessage;
>
>    @Inject
>    private Session session;
>
>    velocityMailMessage.get().from("Seam Framework", "seam at jboss.org")
>          .to(person.getName(), person.getEmail())
>          .subject("HTML Message from Seam Mail - " +
> java.util.UUID.randomUUID().toString())
>          .templateHTMLFromClassPath("template.html.vm")
>          .put("version", "Seam 3")
>          .importance(MessagePriority.HIGH)
>          .addAttachment(new URL("
> http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png"),
> "seamLogo.png", ContentDisposition.INLINE);
>          .send(session);
>
> We look forward to your feedback.
>
> -Dan
>
> [1] http://github.com/seam/mail
> http://seamframework.org/Seam3/Mail
>
> --
> Dan Allen
> Principal Software Engineer, Red Hat | Author of Seam in Action
> Registered Linux User #231597
>
> http://www.google.com/profiles/dan.j.allen#about
> http://mojavelinux.com
> http://mojavelinux.com/seaminaction
>
>  _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>
>
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>
>


-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20110207/acfbe739/attachment.html 


More information about the seam-dev mailing list