[Yanel-commits] rev 47278 - public/yanel/trunk/src/core/java/org/wyona/yanel/core/util

michi at wyona.com michi at wyona.com
Wed Jan 27 12:13:58 CET 2010


Author: michi
Date: 2010-01-27 12:13:58 +0100 (Wed, 27 Jan 2010)
New Revision: 47278

Modified:
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/MailUtil.java
Log:
reply to address added

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/MailUtil.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/MailUtil.java	2010-01-27 10:53:22 UTC (rev 47277)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/MailUtil.java	2010-01-27 11:13:58 UTC (rev 47278)
@@ -21,18 +21,36 @@
 
     /**
      * @param from From address
-     * @param from To address
+     * @param to To address
      * @param subject Subject of email
      * @param content Body of email
      */
     public static void send(String from, String to, String subject, String content) throws AddressException, MessagingException {
-        send(null, -1, from, to, subject, content);
+        send(null, -1, from, null, to, subject, content);
     }
 
     /**
+     * @param from From address
+     * @param replyTo email address (if null, then no reply-to will be set)
+     * @param to To address
+     * @param subject Subject of email
+     * @param content Body of email
+     */
+    public static void send(String from, String replyTo, String to, String subject, String content) throws AddressException, MessagingException {
+        send(null, -1, from, replyTo, to, subject, content);
+    }
+
+    /**
      *
      */
     public static void send(String smtpHost, int smtpPort, String from, String to, String subject, String content) throws AddressException, MessagingException {
+        send(null, -1, from, null, to, subject, content);
+    }
+
+    /**
+     * @param replyTo email address (if null, then no reply-to will be set)
+     */
+    public static void send(String smtpHost, int smtpPort, String from, String replyTo, String to, String subject, String content) throws AddressException, MessagingException {
         // Create a mail session
         Session session = null;
         if (smtpHost != null && smtpPort >= 0) {
@@ -52,6 +70,11 @@
         // Construct the message
         Message msg = new MimeMessage(session);
         msg.setFrom(new InternetAddress(from));
+        if (replyTo != null) {
+            InternetAddress[] replyToAddresses = new InternetAddress[1];
+            replyToAddresses[0] = new InternetAddress(replyTo);
+            msg.setReplyTo(replyToAddresses);
+        }
         msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
         msg.setSubject(subject);
         msg.setText(content);



More information about the Yanel-commits mailing list