geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r351843 - in /geronimo: specs/trunk/geronimo-spec-javamail/src/java/javax/mail/internet/InternetHeaders.java trunk/sandbox/mail/project.xml trunk/sandbox/mail/src/java/org/apache/geronimo/mail/smtp/SMTPTransport.java
Date Fri, 02 Dec 2005 22:08:19 GMT
Author: dain
Date: Fri Dec  2 14:08:15 2005
New Revision: 351843

URL: http://svn.apache.org/viewcvs?rev=351843&view=rev
Log:
GERONIMO-1211 fixes to javamail smtp transport
Thanks Rick!

Modified:
    geronimo/specs/trunk/geronimo-spec-javamail/src/java/javax/mail/internet/InternetHeaders.java
    geronimo/trunk/sandbox/mail/project.xml
    geronimo/trunk/sandbox/mail/src/java/org/apache/geronimo/mail/smtp/SMTPTransport.java

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/java/javax/mail/internet/InternetHeaders.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/java/javax/mail/internet/InternetHeaders.java?rev=351843&r1=351842&r2=351843&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/java/javax/mail/internet/InternetHeaders.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/java/javax/mail/internet/InternetHeaders.java
Fri Dec  2 14:08:15 2005
@@ -330,7 +330,7 @@
         List list = new ArrayList(addresses.length);
         for (int i = 0; i < addresses.length; i++) {
             Address address = addresses[i];
-            list.add(address.toString());
+            list.add(new InternetHeader(name, address.toString()));
         }
         headers.put(name, list);
     }

Modified: geronimo/trunk/sandbox/mail/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/mail/project.xml?rev=351843&r1=351842&r2=351843&view=diff
==============================================================================
--- geronimo/trunk/sandbox/mail/project.xml (original)
+++ geronimo/trunk/sandbox/mail/project.xml Fri Dec  2 14:08:15 2005
@@ -48,21 +48,16 @@
     <!-- ============ -->
 
     <dependencies>
-
-        <!-- Module Dependencies -->
-
         <dependency>
-            <groupId>geronimo-sandbox</groupId>
-            <artifactId>geronimo-sandbox-activation</artifactId>
-            <version>${pom.currentVersion}</version>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-activation</artifactId>
+            <version>${geronimo_spec_activation_version}</version>
         </dependency>
 
         <dependency>
-            <groupId>geronimo-sandbox</groupId>
-            <artifactId>geronimo-sandbox-javamail</artifactId>
-            <version>${pom.currentVersion}</version>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-javamail</artifactId>
+            <version>${geronimo_spec_javamail_version}</version>
         </dependency>
-
     </dependencies>
-
 </project>

Modified: geronimo/trunk/sandbox/mail/src/java/org/apache/geronimo/mail/smtp/SMTPTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/mail/src/java/org/apache/geronimo/mail/smtp/SMTPTransport.java?rev=351843&r1=351842&r2=351843&view=diff
==============================================================================
--- geronimo/trunk/sandbox/mail/src/java/org/apache/geronimo/mail/smtp/SMTPTransport.java
(original)
+++ geronimo/trunk/sandbox/mail/src/java/org/apache/geronimo/mail/smtp/SMTPTransport.java
Fri Dec  2 14:08:15 2005
@@ -21,6 +21,7 @@
 import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.Session;
+import javax.mail.Transport;
 import javax.mail.URLName;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.InternetAddress;
@@ -307,7 +308,7 @@
             throw new SMTPTransportException("invalid address");
         }
 
-        String msg = "RCPT TO: " + addr;
+        String msg = "RCPT TO: " + fixEmailAddress(addr);
 
         sendLine(s, msg);
 
@@ -335,7 +336,7 @@
          * TODO - what do we do w/ more than one from???
          */
 
-        String msg = "MAIL FROM: " + from[0].toString();
+        String msg = "MAIL FROM: " + fixEmailAddress(from[0].toString());
 
         sendLine(s, msg);
 
@@ -561,20 +562,44 @@
         return s;
     }
 
+    private String fixEmailAddress(String mail)
+    {
+        if (mail.charAt(0) == '<') {
+            return mail;
+        }
+        return "<" + mail + ">";
+    }
+
     public static void main(String[] args)
         throws Exception {
 
         Properties props = new Properties();
-        props.setProperty("mail.host", "mail.optonline.net");
+        props.setProperty("mail.host", "localhost");
+        props.setProperty("mail.transport.protocol", "smtp");
+//      props.setProperty("mail.smtp.class", "org.apache.geronimo.mail.SMTPTransport");
 
-        Session session = Session.getDefaultInstance(props);
+        Session session = Session.getInstance(props);
 
         session.setDebug(true);
 
-        SMTPTransport t = new SMTPTransport(session, null);
+        Transport t = session.getTransport("smtp");
 
         MimeMessage msg = new MimeMessage(session);
 
+        msg.setFrom(new InternetAddress("chris@email.com"));
+        msg.addRecipients(Message.RecipientType.TO, "rickmcg@gmail.com");
+        msg.setSubject("From SMTPTransport : this is the second subject");
+        msg.setText("This is the second content (via SMTPTransport)");
+        try {
+
+            t.connect();
+            t.sendMessage(msg, new Address[] {new InternetAddress("rick@us.ibm.com")});
+        } catch (Throwable e) {
+            System.out.println("Exception received: " + e);
+            e.printStackTrace();
+        }
+
+/*
         MimeMultipart mmpt = new MimeMultipart();
         MimeBodyPart b1 = new MimeBodyPart();
         b1.setContent("body 1", "text/plain");
@@ -586,18 +611,24 @@
         mmpt.addBodyPart(b1);
 
         Address[] list = new Address[1];
-        list[0] =  new InternetAddress("geirm@optonline.net");
+        list[0] =  new InternetAddress("rick@us.ibm.com");
 //        list[1] =  new InternetAddress("jeremy@boynes.com");
 
         msg.setSubject("From SMTPTransport : this is the subject");
-        msg.setFrom(new InternetAddress("geirm@optonline.net"));
-//        msg.setContent("This is the content (via SMTPTransport)", "text/plain");
+        msg.setFrom(new InternetAddress("rickmcg@gmail.com"));
+        msg.setContent("This is the content (via SMTPTransport)", "text/plain");
         msg.setRecipients(Message.RecipientType.TO, list);
-        msg.setContent(mmpt);
+//        msg.setContent(mmpt);
 
         msg.setSentDate(new Date());
 
-        t.sendMessage(msg, list);
+        try {
+            t.sendMessage(msg, list);
+        } catch (Throwable e) {
+            System.out.println("Exception received: " + e);
+            e.printStackTrace();
+        }
+        */
     }
 
     /**



Mime
View raw message