Java Mail - Small problem

I've just installed Javamail and I've gotten the demo servlet working. However I've compiled my own Javamail servlet, but it doesn't seem to be working. It compiles correctly, but it doesn't send the email. I have the correct settings for the SMTP and I was told, since I'm using my own computer, "localhost" would do for the name of the SMTP server. They both compile correctly and I've the mail server address I have is correct. Any ideas?
package email12;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import business.User;
import data.UserIO;
import util.MailUtil;
public class EmailServlet extends HttpServlet{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{
String emailAddress = "[email protected]";
String firstName = "Noel";
String to = "[email protected]";
String from = "[email protected]";
String subject = "Test Email";
String message = "Dear " + firstName + ",\n" +
"This is a test email";
try{
MailUtil.sendMail(to, from, subject, message);
catch (MessagingException me){
log("MessagingException: " + emailAddress);
log(me.toString());
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(
"/email11/show_email_entry.jsp");
dispatcher.forward(request, response);
package util;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class MailUtil{
public static void sendMail(String to, String from,
String subject, String messageText)
throws MessagingException{
// 1 - get a mail session
Properties props = new Properties();
props.put("mail.whatever.ie", "localhost");
Session session = Session.getDefaultInstance(props);
// 2 - create a message
MimeMessage message = new MimeMessage(session);
message.setSubject(subject);
message.setText(messageText);
// 3 - address the message
InternetAddress fromAddress = new InternetAddress(from);
InternetAddress toAddress = new InternetAddress(to);
message.setFrom(fromAddress);
message.setRecipient(Message.RecipientType.TO, toAddress);
// 4 - send the message
Transport.send(message);
}

But how come when I use the demo program which comes in the Javamail-1.3 folder, it sends the email for me. So wouldn't that mean that there is a smtp server running? This is where the demo is and how it runs:
http://java.sun.com/developer/onlineTraining/JavaMail/exercises/MailSetup/index.html
import java.io.*;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.*;
* Demo app that shows how to construct and send an RFC822
* (singlepart) message.
* XXX - allow more than one recipient on the command line
* @author Max Spivak
* @author Bill Shannon
public class msgsend {
public static void main(String[] argv) {
     new msgsend(argv);
public msgsend(String[] argv) {
     String to, subject = null, from = null,
          cc = null, bcc = null, url = null;
     String mailhost = null;
     String mailer = "msgsend";
     String protocol = null, host = null, user = null, password = null;
     String record = null;     // name of folder in which to record mail
     boolean debug = false;
     BufferedReader in =
               new BufferedReader(new InputStreamReader(System.in));
     int optind;
     for (optind = 0; optind < argv.length; optind++) {
     if (argv[optind].equals("-T")) {
          protocol = argv[++optind];
     } else if (argv[optind].equals("-H")) {
          host = argv[++optind];
     } else if (argv[optind].equals("-U")) {
          user = argv[++optind];
     } else if (argv[optind].equals("-P")) {
          password = argv[++optind];
     } else if (argv[optind].equals("-M")) {
          mailhost = argv[++optind];
     } else if (argv[optind].equals("-f")) {
          record = argv[++optind];
     } else if (argv[optind].equals("-s")) {
          subject = argv[++optind];
     } else if (argv[optind].equals("-o")) { // originator
          from = argv[++optind];
     } else if (argv[optind].equals("-c")) {
          cc = argv[++optind];
     } else if (argv[optind].equals("-b")) {
          bcc = argv[++optind];
     } else if (argv[optind].equals("-L")) {
          url = argv[++optind];
     } else if (argv[optind].equals("-d")) {
          debug = true;
     } else if (argv[optind].equals("--")) {
          optind++;
          break;
     } else if (argv[optind].startsWith("-")) {
          System.out.println(
"Usage: msgsend [[-L store-url] | [-T prot] [-H host] [-U user] [-P passwd]]");
          System.out.println(
"\t[-s subject] [-o from-address] [-c cc-addresses] [-b bcc-addresses]");
          System.out.println(
"\t[-f record-mailbox] [-M transport-host] [-d] [address]");
          System.exit(1);
     } else {
          break;
     try {
     if (optind < argv.length) {
          // XXX - concatenate all remaining arguments
          to = argv[optind];
          System.out.println("To: " + to);
     } else {
          System.out.print("To: ");
          System.out.flush();
          to = in.readLine();
     if (subject == null) {
          System.out.print("Subject: ");
          System.out.flush();
          subject = in.readLine();
     } else {
          System.out.println("Subject: " + subject);
     Properties props = System.getProperties();
     // XXX - could use Session.getTransport() and Transport.connect()
     // XXX - assume we're using SMTP
     if (mailhost != null)
          props.put("mail.smtp.host", mailhost);
     // Get a Session object
     Session session = Session.getDefaultInstance(props, null);
     if (debug)
          session.setDebug(true);
     // construct the message
     Message msg = new MimeMessage(session);
     if (from != null)
          msg.setFrom(new InternetAddress(from));
     else
          msg.setFrom();
     msg.setRecipients(Message.RecipientType.TO,
                         InternetAddress.parse(to, false));
     if (cc != null)
          msg.setRecipients(Message.RecipientType.CC,
                         InternetAddress.parse(cc, false));
     if (bcc != null)
          msg.setRecipients(Message.RecipientType.BCC,
                         InternetAddress.parse(bcc, false));
     msg.setSubject(subject);
     collect(in, msg);
     msg.setHeader("X-Mailer", mailer);
     msg.setSentDate(new Date());
     // send the thing off
     Transport.send(msg);
     System.out.println("\nMail was sent successfully.");
     // Keep a copy, if requested.
     if (record != null) {
          // Get a Store object
          Store store = null;
          if (url != null) {
          URLName urln = new URLName(url);
          store = session.getStore(urln);
          store.connect();
          } else {
          if (protocol != null)          
               store = session.getStore(protocol);
          else
               store = session.getStore();
          // Connect
          if (host != null || user != null || password != null)
               store.connect(host, user, password);
          else
               store.connect();
          // Get record Folder. Create if it does not exist.
          Folder folder = store.getFolder(record);
          if (folder == null) {
          System.err.println("Can't get record folder.");
          System.exit(1);
          if (!folder.exists())
          folder.create(Folder.HOLDS_MESSAGES);
          Message[] msgs = new Message[1];
          msgs[0] = msg;
          folder.appendMessages(msgs);
          System.out.println("Mail was recorded successfully.");
     } catch (Exception e) {
     e.printStackTrace();
public void collect(BufferedReader in, Message msg)
                         throws MessagingException, IOException {
     String line;
     StringBuffer sb = new StringBuffer();
     while ((line = in.readLine()) != null) {
     sb.append(line);
     sb.append("\n");
     // If the desired charset is known, you can use
     // setText(text, charset)
     msg.setText(sb.toString());
}

Similar Messages

  • Java mail reader problem

    hi
    Geeting following exception while connecting to Exchange Mail server to Read my inbox
    javax.mail.AuthenticationFailedException: The requested mailbox is not available on this server
    could you please help me.... :)

    Supply the correct username and password.
    See the JavaMail FAQ if you're stuck.

  • Problem in using 'ReceivedDateTerm' in Java Mail

    Hi there,
    I have problem in using 'ReceivedDateTerm' in Java Mail. I am able to search on all other criterias but when I try any kind of date search I don't get any message back. For example I send an email and then I try to search that email using the following code I don't get any message back:
    ReceivedDateTerm dateTerm = new ReceivedDateTerm(ComparisonTerm.EQ, new Date());
    SearchTerm term = dateTerm;
    // Other code
    // Get messages
    Message[] msgs = folder.search(term);
    Please help???
    Thanks & Regards,
    Ajay Singh

    The documentation for those classes is absolutely horrible. For example it doesn't say whether the time component of the Date is used, or ignored. It's possible you are asking to find all messages that were received at the exact millisecond you ran that code.

  • Java Mail problem

    I want to used java mail api code in sun application server.But i hava a problem with configuration about HOST:
    String from = "[email protected]";
    String host = "http://localhost:4848/";
    Properties props = new Properties();
    props.put("mail.smtp.host", host);

    Nayana,
    host name should be your mail server name
    Eg: mail.google.com

  • Problem in sending messages using java mail api

    Hi All,
    I have a problem in sending messages via java mail api.
    MimeMessage message = new MimeMessage(session);
    String bodyContent = "ñSunJava";
    message.setText (bodyContent,"utf-8");using the above code its not possible for me to send the attachment. if i am using the below code means special characters like ñ gets removed or changed into some other characters.
    MimeBodyPart messagePart = new MimeBodyPart();
                messagePart.setText(bodyText);
                // Set the email attachment file
                MimeBodyPart attachmentPart = new MimeBodyPart();
                FileDataSource fileDataSource = new FileDataSource("C:/sunjava.txt") {
                    public String getContentType() {
                        return "application/octet-stream";
                attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                attachmentPart.setFileName(filename);
                Multipart multipart = new MimeMultipart();
                multipart.addBodyPart(messagePart);
                multipart.addBodyPart(attachmentPart);
                message.setContent(multipart);
                Transport.send(message);is there any way to send the file attachment with the body message without using MultiPart java class.

    Taken pretty much straight out of the Javamail examples the following works for me (mail read using Thunderbird)        // Define message
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            // Set the 'to' address
            for (int i = 0; i < to.length; i++)
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    // Set the 'cc' address
    for (int i = 0; i < cc.length; i++)
    message.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
    // Set the 'bcc' address
    for (int i = 0; i < bcc.length; i++)
    message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
    message.setSubject("JavaMail With Attachment");
    // Create the message part
    BodyPart messageBodyPart = new MimeBodyPart();
    // Fill the message
    messageBodyPart.setText("Here's the file ñSunJava");
    // Create a Multipart
    Multipart multipart = new MimeMultipart();
    // Add part one
    multipart.addBodyPart(messageBodyPart);
    // Part two is attachment
    for (int count = 0; count < 5; count++)
    String filename = "hello" + count + ".txt";
    String fileContent = " ñSunJava - Now is the time for all good men to come to the aid of the party " + count + " \n";
    // Create another body part
    BodyPart attachementBodyPart = new MimeBodyPart();
    // Get the attachment
    DataSource source = new StringDataSource(fileContent, filename);
    // Set the data handler to this attachment
    attachementBodyPart.setDataHandler(new DataHandler(source));
    // Set the filename
    attachementBodyPart.setFileName(filename);
    // Add this part
    multipart.addBodyPart(attachementBodyPart);
    // Put parts in message
    message.setContent(multipart);
    // Send the message
    Transport.send(message);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problem in retrieving email using java mail api

    hi,
    In my project,i am retrieving mails from a particular email id.
    I am able to retrieve the latest mails and save it in a folder in my system.
    The problem is whenever i run the program eventhough the most recently received mail in inbox is retrieved and saved,again it is retrieving the same one and saving it in the same folder(not repeating).
    I tried to check the newmessages in the inbox using the folder.hasNewMessage() method in java mail api,but the method is returning false only regardless new mail is there in inbox or not.
    I want to read the unread messages only.Dont want to retrieve the already read mails.
    I got the mail retrieving code from the below site.(sorry not posting the code because it is so long and having 4 classes)
    http://www.builderau.com.au/program/java/soa/Getting_the_mail_in_receiving_in_JavaMail/0,39024620,39228060,00.htm
    Can anyone tell me how to read unread mails in the inbox?
    Thanks a lot

    hi parvathi
    i think your mail program is receving mails using imap
    the imap is only receve the mail from server but the pop is deleting the mails after receving
    use the following sample code
    package com.sfrc.mail.pop;
    import javax.mail.*;
    import javax.mail.internet.*;
    import com.sun.mail.handlers.message_rfc822;
    import java.util.*;
    import java.io.*;
    * Owner: SFRC IT Solutions Pvt Ltd
    * Author:Arunkumar Subramaniam
    * Date :12-06-2006
    * File Name: AttachRecive.java
    public class AttachRecive
    public static void main(String args[])
    try
    String popServer="192.168.1.1";
    String popUser="pl";
    String popPassword="password";
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = session.getStore("pop3");
    store.connect(popServer, popUser, popPassword);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message =folder.getMessages();
    Multipart mp = (Multipart)message.getContent();
    for (int i=0, n=mp.getCount(); i<n; i++) {
    Part part = mp.getBodyPart(i);
    String disposition = part.getDisposition();
    // Close connection
    folder.close(false);
    store.close();
    catch (Exception ex)
    System.out.println("Usage: "
    +" popServer popUser popPassword");
    System.exit(0);
    Regards
    Arunkumar Subramaniam
    SFRC IT Solutions Pvt Ltd
    Chennai

  • Problem using Java Mail API with WLS 7.0

    Hi All,
    I am trying to use the Java Mail API provided by WLS 7.0. I have made the
    settings metioned in the WLS 7.0 docs. However when I try to run the program I
    am getting the following error:
    javax.naming.NoInitialContextException: Need to specify class name in environment
    or system property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    46)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:283)
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    The code that I have written is as follows
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
         public static void main(String args[])
              try
                   //Context ic = getInitialContext();
                   InitialContext ic = new InitialContext();
    /* My jndi name is "testSession" */
                   Session session = (Session) ic.lookup("testSession"); /* THE PROBLEM IS SHOWN
    IN THIS LINE */
                   Properties props = new Properties();
                   props.put("mail.transport.protocol", "smtp");
                   props.put("mail.smtp.host", "XX.XX.XX.XX");
    /* For security reasons I have written the ip add in this format */
                   props.put("mail.from", "[email protected]"); /* for security reasons i have
    changed the mail address */
                   Session session2 = session.getInstance(props);
                   Message msg = new MimeMessage(session2);
                   msg.setFrom();
                   msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]",
    false));
                   msg.setSubject("Test Message");
                   msg.setSentDate(new Date());
                   MimeBodyPart mbp = new MimeBodyPart();
                   mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
                   Multipart mp = new MimeMultipart();
                   mp.addBodyPart(mbp);
                   msg.setContent(mp);
                   Transport.send(msg);
              catch(Exception e)
                   e.printStackTrace();
         }//end of main
    public static Context getInitialContext()
         throws NamingException
              Properties p = new Properties();
              p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
              p.put(Context.PROVIDER_URL, "t3://localhost:7501/testWebApp");
                   p.put(Context.SECURITY_PRINCIPAL, "weblogic");
                   p.put(Context.SECURITY_CREDENTIALS, "weblogic");
              return new InitialContext(p);
    }//end of class
    Can anyone please tell me what is the problem. I thought that we cannot directly
    do
    InitialContext ic = new InitialContext();
    So I had written a method getInitialContext() as shown in the above piece of code,
    but that too did not work.
    Eagerly awaiting a response.
    Jimmy Shah

    You can use InitialContext ic = new InitialContext() only if you are using a startup class, servlet or a JSP i.e
    server side code.
    If you are using a java client you need to use Context ic = getInitialContext();
    Try this code
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
    public static void main(String args[])
    try {
    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL, "t3://localhost:7001");
    Context ic = new InitialContext(h);
    Session session = (Session) ic.lookup("testSession");
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", "XX.XX.XX.XX");
    props.put("mail.from", "[email protected]");
    Session session2 = session.getInstance(props);
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse("[email protected]",false));
    msg.setSubject("Test Message");
    msg.setSentDate(new Date());
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    Transport.send(msg);
    catch(Exception e)
    e.printStackTrace();
    }//end of main
    }//end of class
    We have shipped a javamail example in the samples\server\src\examples\javamail folder.
    Jimmy Shah wrote:
    Hi All,
    I am trying to use the Java Mail API provided by WLS 7.0. I have made the
    settings metioned in the WLS 7.0 docs. However when I try to run the program I
    am getting the following error:
    javax.naming.NoInitialContextException: Need to specify class name in environment
    or system property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    46)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:283)
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    The code that I have written is as follows
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
    public static void main(String args[])
    try
    //Context ic = getInitialContext();
    InitialContext ic = new InitialContext();
    /* My jndi name is "testSession" */
    Session session = (Session) ic.lookup("testSession"); /* THE PROBLEM IS SHOWN
    IN THIS LINE */
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", "XX.XX.XX.XX");
    /* For security reasons I have written the ip add in this format */
    props.put("mail.from", "[email protected]"); /* for security reasons i have
    changed the mail address */
    Session session2 = session.getInstance(props);
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]",
    false));
    msg.setSubject("Test Message");
    msg.setSentDate(new Date());
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    Transport.send(msg);
    catch(Exception e)
    e.printStackTrace();
    }//end of main
    public static Context getInitialContext()
    throws NamingException
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, "t3://localhost:7501/testWebApp");
    p.put(Context.SECURITY_PRINCIPAL, "weblogic");
    p.put(Context.SECURITY_CREDENTIALS, "weblogic");
    return new InitialContext(p);
    }//end of class
    Can anyone please tell me what is the problem. I thought that we cannot directly
    do
    InitialContext ic = new InitialContext();
    So I had written a method getInitialContext() as shown in the above piece of code,
    but that too did not work.
    Eagerly awaiting a response.
    Jimmy Shah--
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support

  • Problem with sending mail throgh java mail api

    hi folks,
    We are having problem regarding sending mail using java mail api.
    we are using msgsendsample.java file from demo folder contained in javamail-1.3.3_01 folder.
    we are using following command at dos prompt.:
    java msgsendsample [email protected] [email protected] smtp.mail.yahoo.com false
    It gives following Exception:
    --Exception handling in msgsendsample.java
    com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for hel
    p go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
    333) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:906)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:535)
    at javax.mail.Transport.send0(Transport.java:151)
    at javax.mail.Transport.send(Transport.java:80)
    at msgsendsample.main(msgsendsample.java:93)
    ** ValidUnsent Addresses
    [email protected]
    Thanking in Advance...
    Please give us guidance to any alternate solution if exists.

    hi
    the smtp server u are using should allow u to send mail to other smtp server like if u r sending mail to yahoo account u have to use yahoo smtp server only .....
    bye

  • Problems while sending mail using java mail..help...

    Hello all,
    I am new to Java Mail...
    Below is my first program...
    Can anybody tell what's wrong in it..??
    Thanks in advance....
    ------------------------------------------------------start--------------------
    package test;
    import java.util.Properties;
    import javax.mail.Address;
    import javax.mail.Authenticator;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.Message.RecipientType;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class Send
         public Send()
         public void send()
              java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              Properties props=new Properties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.host","smtp.gmail.com");
              props.put("mail.smtp.port","25");
              props.put("mail.smtp.auth","true");
              Session session=Session.getDefaultInstance(props,new MyAuthenticator());
              session.setDebug(true);
              MimeMessage message=new MimeMessage(session);
              try
                   message.setContent("Hello ...","text/plain");
                   message.setSubject("Test mail...plz don't ignore..");
                   Address to=new InternetAddress("[email protected]");
                   Address from=new InternetAddress("[email protected]");
                   Address replyTo=new InternetAddress("[email protected]");
                   message.setFrom(from);
                   message.setReplyTo(new Address[]{replyTo});
                   message.setRecipient(RecipientType.TO,to);               
                   Transport.send(message);
              } catch (AddressException e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (NoSuchProviderException e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (MessagingException e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args)
              new Send().send();          
         class MyAuthenticator extends Authenticator
              MyAuthenticator()
                   super();
              protected PasswordAuthentication getPasswordAuthentication()
                   return new PasswordAuthentication("[email protected]", "*******");
    --------------------------------------------end--------------
    here is the output.....
    DEBUG: setDebug: JavaMail version 1.3.2
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 25, isSSL false
    220 mx.gmail.com ESMTP 16sm2443823wrl
    DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
    EHLO jijo
    250-mx.gmail.com at your service
    250-SIZE 20971520
    250-8BITMIME
    250-STARTTLS
    250 ENHANCEDSTATUSCODES
    DEBUG SMTP: Found extension "SIZE", arg "20971520"
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: Found extension "STARTTLS", arg ""
    DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    530 5.7.0 Must issue a STARTTLS command first
    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
         at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at test.Send.send(Send.java:50)
         at test.Send.main(Send.java:68)
    QUIT
    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
         at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at test.Send.send(Send.java:50)
         at test.Send.main(Send.java:68)
    Can any body help me..??
    Thanks and Regards
    Jijo vincent

    Hi All,
    I am new to javax.mail.
    I have attached my code and also error here...
    can anyone help to resolve the error?
    Code:
    public class MailExample {
         public static void main(String args[]) {
              try {
              String host = "localhost"; //args[0];
              String from = "[email protected]"; //args[1];
    //          String to = "[email protected]";//args[2];
              String to = "[email protected]";//args[2];
              java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              // Get system properties
              Properties props = System.getProperties();
              // Setup mail server
              props.put("mail.smtp.host", host);
              props.put("mail.smtp.starttls.enable","true");
              //props.put("mail.smtp.auth","true");
              // Get session
              Session session = Session.getDefaultInstance(props, null);
              session.setDebug(true);
              // Define message
              MimeMessage message = new MimeMessage(session);
              // Set the from address
              message.setFrom(new InternetAddress(from));
              // Set the to address
              message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
              // Set the subject
              message.setSubject("Hello JavaMail");
              // Set the content
              message.setText("Welcome to JavaMail");
              // Send message
              Transport.send(message);
              catch(AddressException ae){
                   ae.printStackTrace();
              }catch (MessagingException e)
    //               TODO Auto-generated catch block
                   e.printStackTrace();
    Error:
    DEBUG: setDebug: JavaMail version 1.3.3ea
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "localhost", port 25, isSSL false
    220 localhost
    DEBUG SMTP: connected to host "localhost", port: 25
    EHLO HDCHCTDAM33726
    250-localhost
    250 HELP
    DEBUG SMTP: Found extension "HELP", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 [email protected] Address Okay
    RCPT TO:<[email protected]>
    250 [email protected] Address Okay
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP: [email protected]
    DATA
    354 Start mail input; end with <CRLF>.<CRLF>
    Message-ID: <10736847.01125315340863.JavaMail.sangeetham@HDCHCTDAM33726>
    From: [email protected]
    To: [email protected]
    Subject: Hello JavaMail
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Welcome to JavaMail
    com.sun.mail.smtp.SMTPSendFailedException: 550 Invalid recipient: [email protected]
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1333)
         at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1160)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:538)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at org.worldbank.webmfr.util.MailExample.main(MailExample.java:55)550 Invalid recipient: [email protected]
    com.sun.mail.smtp.SMTPSendFailedException: 550 Invalid recipient: [email protected]
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1333)
         at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1160)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:538)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at org.worldbank.webmfr.util.MailExample.main(MailExample.java:55)
    QUIT

  • Jsp java-mail problem.............

    how to send an email from jsp page using java mail?like for submitting a form an email will be sent to the user email-id(the email-id is stored/match-ed in/from the database)???i m using tomcat 5.5 and netbeans 6.5.1...........so what should i do if dont want to use google smtp/pop3 port???

    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    import javax.mail.*;
    import javax.mail.internet.*;
    * Demo app that shows how to construct and send an RFC822
    * (singlepart) message.
    * XXX - allow more than one recipient on the command line
    * @author Max Spivak
    * @author Bill Shannon
    public class msgsend {
        public static void main(String[] argv) {
         String  to, subject = null, from = null,
              cc = null, bcc = null, url = null;
         String mailhost = null;
         String mailer = "msgsend";
         String file = null;
         String protocol = null, host = null, user = null, password = null;
         String record = null;     // name of folder in which to record mail
         boolean debug = false;
         BufferedReader in =
                   new BufferedReader(new InputStreamReader(System.in));
         int optind;
          * Process command line arguments.
         for (optind = 0; optind < argv.length; optind++) {
             if (argv[optind].equals("-T")) {
              protocol = argv[++optind];
             } else if (argv[optind].equals("-H")) {
              host = argv[++optind];
             } else if (argv[optind].equals("-U")) {
              user = argv[++optind];
             } else if (argv[optind].equals("-P")) {
              password = argv[++optind];
             } else if (argv[optind].equals("-M")) {
              mailhost = argv[++optind];
             } else if (argv[optind].equals("-f")) {
              record = argv[++optind];
             } else if (argv[optind].equals("-a")) {
              file = argv[++optind];
             } else if (argv[optind].equals("-s")) {
              subject = argv[++optind];
             } else if (argv[optind].equals("-o")) { // originator
              from = argv[++optind];
             } else if (argv[optind].equals("-c")) {
              cc = argv[++optind];
             } else if (argv[optind].equals("-b")) {
              bcc = argv[++optind];
             } else if (argv[optind].equals("-L")) {
              url = argv[++optind];
             } else if (argv[optind].equals("-d")) {
              debug = true;
             } else if (argv[optind].equals("--")) {
              optind++;
              break;
             } else if (argv[optind].startsWith("-")) {
              System.out.println(
    "Usage: msgsend [[-L store-url] | [-T prot] [-H host] [-U user] [-P passwd]]");
              System.out.println(
    "\t[-s subject] [-o from-address] [-c cc-addresses] [-b bcc-addresses]");
              System.out.println(
    "\t[-f record-mailbox] [-M transport-host] [-a attach-file] [-d] [address]");
              System.exit(1);
             } else {
              break;
         try {
              * Prompt for To and Subject, if not specified.
             if (optind < argv.length) {
              // XXX - concatenate all remaining arguments
              to = argv[optind];
              System.out.println("To: " + to);
             } else {
              System.out.print("To: ");
              System.out.flush();
              to = in.readLine();
             if (subject == null) {
              System.out.print("Subject: ");
              System.out.flush();
              subject = in.readLine();
             } else {
              System.out.println("Subject: " + subject);
              * Initialize the JavaMail Session.
             Properties props = System.getProperties();
             // XXX - could use Session.getTransport() and Transport.connect()
             // XXX - assume we're using SMTP
             if (mailhost != null)
              props.put("mail.smtp.host", mailhost);
             // Get a Session object
             Session session = Session.getInstance(props, null);
             if (debug)
              session.setDebug(true);
              * Construct the message and send it.
             Message msg = new MimeMessage(session);
             if (from != null)
              msg.setFrom(new InternetAddress(from));
             else
              msg.setFrom();
             msg.setRecipients(Message.RecipientType.TO,
                             InternetAddress.parse(to, false));
             if (cc != null)
              msg.setRecipients(Message.RecipientType.CC,
                             InternetAddress.parse(cc, false));
             if (bcc != null)
              msg.setRecipients(Message.RecipientType.BCC,
                             InternetAddress.parse(bcc, false));
             msg.setSubject(subject);
             String text = collect(in);
             if (file != null) {
              // Attach the specified file.
              // We need a multipart message to hold the attachment.
              MimeBodyPart mbp1 = new MimeBodyPart();
              mbp1.setText(text);
              MimeBodyPart mbp2 = new MimeBodyPart();
              mbp2.attachFile(file);
              MimeMultipart mp = new MimeMultipart();
              mp.addBodyPart(mbp1);
              mp.addBodyPart(mbp2);
              msg.setContent(mp);
             } else {
              // If the desired charset is known, you can use
              // setText(text, charset)
              msg.setText(text);
             msg.setHeader("X-Mailer", mailer);
             msg.setSentDate(new Date());
             // send the thing off
             Transport.send(msg);
             System.out.println("\nMail was sent successfully.");
              * Save a copy of the message, if requested.
             if (record != null) {
              // Get a Store object
              Store store = null;
              if (url != null) {
                  URLName urln = new URLName(url);
                  store = session.getStore(urln);
                  store.connect();
              } else {
                  if (protocol != null)          
                   store = session.getStore(protocol);
                  else
                   store = session.getStore();
                  // Connect
                  if (host != null || user != null || password != null)
                   store.connect(host, user, password);
                  else
                   store.connect();
              // Get record Folder.  Create if it does not exist.
              Folder folder = store.getFolder(record);
              if (folder == null) {
                  System.err.println("Can't get record folder.");
                  System.exit(1);
              if (!folder.exists())
                  folder.create(Folder.HOLDS_MESSAGES);
              Message[] msgs = new Message[1];
              msgs[0] = msg;
              folder.appendMessages(msgs);
              System.out.println("Mail was recorded successfully.");
         } catch (Exception e) {
             e.printStackTrace();
         * Read the body of the message until EOF.
        public static String collect(BufferedReader in) throws IOException {
         String line;
         StringBuffer sb = new StringBuffer();
         while ((line = in.readLine()) != null) {
             sb.append(line);
             sb.append("\n");
         return sb.toString();
    }now what should i do???to call it from jsp???

  • Problem realted java mail api

    hi,
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title> Java Mail </title>
        </head>
        <body>
            <form action="newjsp.jsp" method="POST">
                <table border="0" align="center" cellpadding="5">
                    <tbody>
                        <tr> <td colspan="3" align="center">
                        <b> Send Mail </b> </td> </tr>
                        <tr>
                            <td> To </td> <td> : </td>
                            <td> <input type="text" name="to" value="" /> </td>
                        </tr>
                        <tr>
                            <td> Subject </td> <td> : </td>
                            <td> <input type="text" name="subject" value="" /> </td>
                        </tr>
                        <tr>
                            <td> Message </td> <td> : </td>
                            <td> <textarea name="message" rows="8" cols="30">
                            </textarea></td>
                        </tr>
                        <tr>
                            <td colspan="3" align="center">
                            <input type="submit" value="Send Mail" />
                            <input type="reset" value="Reset" />
                            <td>
                        </tr>
                    </tbody>
                </table>
            </form>
        </body>
    </html>
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package abc;
    * @author bgoyal
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class Mail {
    private String to;
        private String from;
        private String message;
        private String subject;
        private String smtpServ;
         * @return the to
        public String getTo() {
            return to;
         * @param to the to to set
        public void setTo(String to) {
            this.to = to;
         * @return the from
        public String getFrom() {
            return from;
         * @param from the from to set
        public void setFrom(String from) {
            this.from = from;
         * @return the message
        public String getMessage() {
            return message;
         * @param message the message to set
        public void setMessage(String message) {
            this.message = message;
         * @return the subject
        public String getSubject() {
            return subject;
         * @param subject the subject to set
        public void setSubject(String subject) {
            this.subject = subject;
         * @return the smtpServ
        public String getSmtpServ() {
            return smtpServ;
         * @param smtpServ the smtpServ to set
        public void setSmtpServ(String smtpServ) {
            this.smtpServ = smtpServ;
        public int sendMail(){
            try
                Properties props = System.getProperties();
                  // -- Attaching to default Session, or we could start a new one --
                  props.put("mail.transport.protocol", "smtp" );
                  props.put("mail.smtp.starttls.enable","true" );
                  props.put("mail.smtp.host",smtpServ);
                  props.put("mail.smtp.auth", "true" );
                  Authenticator auth = new SMTPAuthenticator();
                  Session session = Session.getInstance(props, auth);
                  // -- Create a new message --
                  Message msg = new MimeMessage(session);
                  // -- Set the FROM and TO fields --
                  msg.setFrom(new InternetAddress(from));
                  msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
                  msg.setSubject(subject);
                  msg.setText(message);
                  // -- Set some other header information --
                  msg.setHeader("MyMail", "Mr. XYZ" );
                  msg.setSentDate(new Date());
                  // -- Send the message --
                  Transport.send(msg);
                  System.out.println("Message sent to"+to+" OK." );
                  return 0;
            catch (Exception ex)
              ex.printStackTrace();
              System.out.println("Exception "+ex);
              return -1;
    // Also include an inner class that is used for authentication purposes
    private class SMTPAuthenticator extends javax.mail.Authenticator {
            @Override
            public PasswordAuthentication getPasswordAuthentication() {
                String username =  "[email protected]";           // specify your email id here (sender's email id)
                String password = "javamail";                                      // specify your password here
                return new PasswordAuthentication(username, password);
    }error is
    type Status report
    message
    descriptionThe requested resource () is not available.
    <%--
        Document   : sendMail.jsp
        Created on : Aug 11, 2009, 1:50:50 PM
        Author     : bgoyal
    --%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1>Hello World!</h1>
            <jsp:useBean id="mail" scope="session" class="abc.Mail" />
    <jsp:setProperty name="mail" property="to" param="to" />
    <jsp:setProperty name="mail" property="from" value="[email protected]" />
    <jsp:setProperty name="mail" property="smtpServ" value="smtp.gmail.com" />
    <jsp:setProperty name="mail" property="subject" param="subject" />
    <jsp:setProperty name="mail" property="message" param="message" />
    <%
    String to = mail.getTo();
    int result;
    result = mail.sendMail();
    if(result == 0){
        out.println(" Mail Successfully Sent to "+to);
    else{
        out.println(" Mail NOT Sent to "+to);
    %>
        </body>
    </html>

    And?

  • Java mail api - sending mails to gmail account

    Hello
    I am using java mail api to send mails.when i send mails to gmail from ids which are not in gmail friends list, most of the mails are going to spam.Ofcourse, some of them go to inbox.I tried in lot of ways to analyse the problem.But nothing could help. Can anyone plzz tell me how to avoid mails going to spam in gmail, using java mail api?
    Thank you in advance,
    Regards,
    Aradhana
    Message was edited by:
    Aradhana

    am using the below code.
    Properties props = System.getProperties();
    //          Setup mail server
              props.put("mail.smtp.host", smtpHost);
              props.put("mail.smtp.port","25");
              props.put("mail.smtp.auth", isAuth);
         Authenticator auth = new UserAuthenticator();
    //          Get session
              Session s = Session.getDefaultInstance(props,auth);
    //          Define message
              Message m = new MimeMessage(s);
    //          setting message attributes
              try {
                   m.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
                   InternetAddress f_addr=new InternetAddress(from);
                   f_addr.setPersonal(personalName);
                   m.setFrom(f_addr);               
                   m.setSubject(subject);
                   m.setSentDate(new Date());
                   m.setContent(msg,"text/plain");
                   m.saveChanges();
    //               send message
                   Transport.send(m);
    Message was edited by:
    Aradhana

  • Exception in java mail API when parsing email

    I am receiving the following exception when receiving some emails that contain attachments with java mail (irrelevant part of stack trace omitted):
    javax.mail.internet.ParseException: Expected ';', got ","
         at javax.mail.internet.ParameterList.<init>(ParameterList.java:289)
         at javax.mail.internet.ContentDisposition.<init>(ContentDisposition.java:100)
         at javax.mail.internet.MimeBodyPart.getFileName(MimeBodyPart.java:1136)
    The header of a message the causes the problem is:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) ------------ Message headers ------------
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from mail2.uscourts.gov ([10.170.250.2])
    by ushub06.uscmail.dcn (Lotus Domino Release 8.5.2FP1 HF3)
    with SMTP id 2011042514392620-733724 ;
    Mon, 25 Apr 2011 14:39:26 -0400
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from (unknown [63.174.91.123]) by avms-usc-04c-02vh.ibmta.uscourts.gov with smtp
         id 191c_067d_57fad3b8_6f6b_11e0_8de9_00265519f638;
         Mon, 25 Apr 2011 18:39:24 +0000
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-WSS-ID: 0LK815L-05-67D-02
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-M-MSG:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from kcmexclaim.Our-Firm.com (unknown [10.42.5.222])by mail4.stinson.com (Axway MailGate 3.8.1) with ESMTP id 27239A12C1D;     Mon, 25 Apr 2011 13:39:20 -0500 (CDT)
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from KCME2K7-HUB02.Our-Firm.com ([10.42.5.19]) by kcmexclaim.Our-Firm.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 25 Apr 2011 13:39:23 -0500
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from FIRMCMS01.Our-Firm.com ([fe80::81d0:dd2b:9983:1126]) by KCME2K7-HUB02.Our-Firm.com ([::1]) with mapi; Mon, 25 Apr 2011 13:39:22 -0500
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) From:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) To:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Cc:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Disposition-Notification-To:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Date: Mon, 25 Apr 2011 13:39:21 -0500
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Subject: Order Regarding Application To Employ SMH as Debtor's Counsel
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Thread-Topic: Order Regarding Application To Employ SMH as Debtor's Counsel
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Thread-Index: AcwDb/bpRQlxt/eTQC6BA7G10hdWJQAB99vQ
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Message-ID: <[email protected]>
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Accept-Language: en-US
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-MS-Has-Attach: yes
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-MS-TNEF-Correlator:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) acceptlanguage: en-US
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Importance: Normal
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Priority: normal
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4841
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) MIME-Version: 1.0
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Return-Path:
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) X-OriginalArrivalTime: 25 Apr 2011 18:39:23.0526 (UTC) FILETIME=[18E10260:01CC0378]
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) X-MIMETrack: Itemize by SMTP Server on USHUB06/H/US/USCOURTS(Release 8.5.2FP1 HF3|December 21, 2010) at 04/25/2011 02:39:26 PM, Serialize by POP3 Server(Release 8.0.2FP3 HF28|December 28, 2009) at 04/25/2011 02:39:47 PM
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Transfer-Encoding: 7bit
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Class: urn:content-classes:message 2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Type: multipart/mixed;     boundary="_004_52835C1F7A6C8D4F989C433DCC611CA06F252D6682FIRMCMS01OurF_"
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Language: en-US
    the client/OS combination of the mail sender is Windows XP service Pack 3/Outlook 2007 , Java Mail version 1.4.3
    Any help would be appreciated
    Edited by: 854778 on Apr 26, 2011 8:28 AM

    The exception is occurring when parsing the Content-Disposition header.
    I don't see that header in the list of headers you provided.
    Can you save the entire message to a text file using
    msg.writeTo(new FileOutputStream("msg.txt"));
    Then look for the Content-Disposition header in msg.txt. Most likely you'll
    find that it is incorrectly formatted - as the exception says, there's a comma
    in a place that a semicolon is expected.

  • Java Mail Madness - Doesn't Work but shows no errors ?

    What's up folks. I am trying to implement the java mail library. Unfortunately, I have a problem and I don't know how to track it down. Here is the code that I run in the Netbeans IDE.
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendApp {
    public static void send(String smtpHost, int smtpPort,
    String from, String to,
    String subject, String content)
    throws AddressException, MessagingException {
    // Create a mail session
    java.util.Properties props = new java.util.Properties();
    props.put("mail.smtp.host", smtpHost);
    props.put("mail.smtp.port", ""+smtpPort);
    Session session = Session.getDefaultInstance(props, null);
    // Construct the message
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
    msg.setSubject(subject);
    msg.setText(content);
    // Send the message
    Transport.send(msg);
    public static void main(String[] args) throws Exception {
    // Send a test message
    send("kernel", 25, "jd@kernel", "[email protected]",
    "re: dinner", "How about at 7?");
    Where kernel is the domain name of my computer. However, when I check my email at [email protected] (fake address) I don't see anything and the program exits with success. I don't know if this is cause of a problem with my Netbeans, my code, or my postfix smtp system. Any help is greatly appreciated !
    SIncerely,
    Justin Dallas

    Hi,
    Did you checked the log for any errors
    catch (Exception e) {
         System.out.println("Exception while sending mail" + e.getMessage());
         e.printStackTrace();
    Or else add the following line in your exception handler and check whether their is any error or not.
    wdComponentAPI.getMessageManager().reportException(e.getMessage());
    Regards
    Ayyapparaj

  • Cannot use Java Mail in Oracle 8i

    I have loaded Sun's API Java Mail (and Java Activator) into
    an Oracle 8.1.5 server running on a Windows NT 4.0 server.
    I have also created a small Java-application that tries to
    send emails. The application is stored in database as a stored
    procedure.
    However, when I try to send a mail through my stored procedure
    I get the message:
    'ORA-01041 internal error. hostdef extension doesn't exist'
    followed by an end-of-channel error.
    It works fine when I run my Java-program stand-alone, without
    any database involved.
    I need some help with this one...
    Regards,
    Lars-Eric
    null

    I got the Java Embedding Activity working...,I used the following imports in my BPEL....
    <bpelx:exec import="java.util.logging.Logger"/>
    <bpelx:exec import="java.util.logging.Level"/>
    <bpelx:exec import="oracle.fabric.logging.LogFormatter"/>
    <bpelx:exec import="org.w3c.dom.*"/>
    <bpelx:exec import="oracle.xml.parser.v2.XMLElement"/>
    <bpelx:exec import="java.util.*"/>
    <bpelx:exec import="java.lang.*"/>
    <bpelx:exec import="java.math.*"/>
    <bpelx:exec import="java.io.*"/>
    <bpelx:exec import="oracle.soa.common.util.Base64Decoder"/>
    Hope this helps anyone who have been struggling like me before...
    Thanks,
    N

Maybe you are looking for

  • IE7 and CSS

    I looked the forum for a topic like this but I didn't find it. I've heard that IE7 does not support correctly the CSS. Is it true? Can I tell my customers to install it? Some of them doesn't want to use Firefox-

  • Is there an external graphics card available for the Mac Mini?

    Is there an external graphics card available for the Mac Mini?

  • My iMac beeps and freezes

    I will be using it and it randomly will stop and freeze than beep three times the only way to stop it is a hard boot up unplugging it only works I had upgraded the ram to the max that a 27 inch 2011 model will take I believe 16 gb

  • What are the most durable headphones?

    I seem to go through headphones left and right (literally), now I know how they're breaking, but that isn't helping me stop them from doing so. I tend to go through a pair every 2-3 weeks. Are there any good durable sets out there? I prefer eat bud b

  • TS3274 How can I access email in My Folders on my iPad?

    I have assigned some email to a folder in My Folders. On my computer I can open the folders but I don't know how to do that on my iPad. Anybody know how that's done?