Quick javax.mail Question

Can anyone tell me if javax.mail is the same as JavaMail API 1.2, if not do you know of a url of where I can download it.
Thanks everyone

Yes, it's the same.

Similar Messages

  • Javax.mail question

    I am working on a project and encounter a problem when I try to use javax.mail package to send email. For some season, I have to use a name without the domain name as the sender (such as Sender rather than Sender @sun.com). I got MessagingException called 501 Syntax error, mail from: <Sender>" unrecognized or missing. When I add the domain name in (subtitute Sender with [email protected]), the program worked. My mail server admin told me there is no restriction on the mail server to regulate the sender's name (also it allows relay messaging). I don't know if she is right because I don't know much about mail server. Also, I figured out that I have no problem with InternetAddress("Sender"). The only thing might have problem is Message.send().
    Anybody has a thought?
    Thanks in advance.

    In an effort to reduce the amount of spam hitting, mail relays are configured to refuse to accept pieces of email whose SMTP envelope's From header isn't resolvable
    If the header in the form of user@host instead of a globally-resolvable [email protected], a bounce message would return to your user with an error message like:
    451 <user@mailhost>... Domain does not resolve
    This means that your mail relay is identifying itself as mailhost rather than mailhost.your.domain.
    How this is fixed will depend on your mail transfer agent and your own DNS. Given that this is very site-specific, I can't provide any more help about host configuration.
    Certain mail user agents (MUAs) like Netscape, Eudora, etc., that want to use an ``SMTP host'' to deliver outgoing mail will write their own SMTP envelope. They'll do this by taking the value that the user provided as their email address (which will appear in the message's From: header and using it in the SMTP envelope From header. A mail transfer agent, configured to use the user's real email address, should be able to send mail to without problem.

  • Getting javax.mail.AuthenticationFailedException: EOF on socket. Need Help

    I am trying to get hotmail emails and store in Oracle 10g database.
    When I am executing receivemail procedure from Oracle 10g database. I am getting following error.
    connect to ESIMSCO_UTIL_OWNER
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<My email address>@hotmail.com', '<My email password>');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I did following steps, but still I am getting this error. Can somebady help me to solve this problem.
    connect sys/<password>@esimsco as sysdba
    connect to sys
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 30 16:02:04 2012
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> begin
    1 dbms_java.grant_permission( 'ESIMSCO_UTIL_OWNER', 'SYS:java.util.PropertyPermission', '*', 'read,write' );
    2 commit;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.net.SocketPermission',
    5 permission_name => '*',
    6 permission_action => 'connect,resolve'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.util.PropertyPermission',
    5 permission_name => '*',
    6 permission_action => 'read,write'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>
    Then I connect ESIMSCO_UTIL_OWNER.
    connect to ESIMSCO_UTIL_OWNER
    Create 2 tables.
    create table attachment(
    at_file varchar2(500),
    at_mimetype varchar2(500),
    at_attachment blob
    create table email (
    em_incident integer,
    em_from varchar2(1000),
    em_subject varchar2(1000),
    em_body nclob
    Then Create java source named receivemail.
    create or replace and compile java source named receivemail as
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    import sqlj.runtime.*;
    import oracle.sql.BLOB;
    public class ReceiveMail
    static void getAttachments(Message message, int incidentNo)
    throws MessagingException, IOException, SQLException {
    //String attachments = "";
    Object content = message.getContent();
    if (content instanceof Multipart)
    // -- Multi part message which may contain attachment
    Multipart multipart = (Multipart)message.getContent();
    // -- Loop through all parts of the message
    for (int i=0, n=multipart.getCount(); i<n; i++) {
    Part part = multipart.getBodyPart(i);
    String disposition = part.getDisposition();
    if ((disposition != null) &&(disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) {
    //-- This part is a file attachment
    String fileName = incidentNo+"_"+part.getFileName().replace(' ','_');
    System.out.println("FILE: " + fileName);
    String contentType = part.getContentType();
    String mimeType = contentType.substring(0,contentType.indexOf(";"));
    System.out.println("FILETYPE: " + mimeType);
    InputStream is = part.getInputStream();
    // -- To work with a BLOB column you have to insert a record
    // -- with an emptly BLOB first.
    #sql { insert into attachment(at_file, at_mimetype, at_attachment)
    values (:fileName, :mimeType, empty_blob()) };
    // -- Retrieve the BLOB
    BLOB attachment = null;
    #sql { select at_attachment into :attachment
    from attachment where at_file = :fileName };
    // -- Fill the BLOB
    OutputStream os = attachment.getBinaryOutputStream();
    int j;
    while ((j = is.read()) != -1) {
    os.write(j);
    is.close();
    os.close();
    // -- Set the BLOB by updating the record
    #sql { update attachment set at_attachment = :attachment
    where at_file = :fileName };
    static String getPlainTextBody(Message message)
    throws MessagingException, IOException
    Object content = message.getContent();
    if (message.isMimeType("text/plain")) {
    // -- Message has plain text body only
    System.out.println("SIMPLE TEXT");
    return (String) content;
    } else if (message.isMimeType("multipart/*")) {
    // -- Message is multipart. Loop through the message parts to retrieve
    // -- the body.
    Multipart mp = (Multipart) message.getContent();
    int numParts = mp.getCount();
    System.out.println("MULTIPART: "+numParts);
    for (int i = 0; i < numParts; ++i) {
    System.out.println("PART: "+mp.getBodyPart(i).getContentType());
    if (mp.getBodyPart(i).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mp.getBodyPart(i).getContent();
    } else if (mp.getBodyPart(i).isMimeType("multipart/*")) {
    // -- Body is also multipart (both plain text and html).
    // -- Loop through the body parts to retrieve plain text part.
    MimeMultipart mmp = (MimeMultipart) mp.getBodyPart(i).getContent();
    int numBodyParts = mmp.getCount();
    System.out.println("MULTIBODYPART: "+numBodyParts);
    for (int j = 0; j < numBodyParts; ++j) {
    System.out.println("BODYPART: "+mmp.getBodyPart(j).getContentType());
    if (mmp.getBodyPart(j).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mmp.getBodyPart(j).getContent();
    return "";
    } else {
    System.out.println("UNKNOWN: "+message.getContentType());
    return "";
    static void saveMessage(Message message)
    throws MessagingException, IOException, SQLException
    //String body = "";
    int incidentNo;
    // -- Get a new incident number
    #sql { select seq_incident.nextval into :incidentNo from dual };
    // -- Get the header information
    String from = ((InternetAddress)message.getFrom()[0]).getAddress();
    System.out.println("FROM: "+ from);
    String subject = message.getSubject();
    System.out.println("SUBJECT: "+subject);
    // -- Retrieve the plain text body
    String body = getPlainTextBody(message);
    // -- Store the message in the email table
    #sql { insert into email (em_incident, em_from, em_subject, em_body)
    values (:incidentNo, :from, :subject, :body) };
    // -- Retrieve the attachments
    getAttachments(message, incidentNo);
    #sql { commit };
    // -- Mark message for deletion
    // message.setFlag(Flags.Flag.DELETED, true);
    public static String Receive(String POP3Server, String usr, String pwd)
    Store store = null;
    Folder folder = null;
    try
    // -- Get hold of the default session --
    Properties props = System.getProperties();
    props.put("mail.pop3.connectiontimeout", "60000");
    Session session = Session.getDefaultInstance(props, null);
    // -- Get hold of a POP3 message store, and connect to it --
    store = session.getStore("pop3");
    store.connect(POP3Server,995, usr, pwd);
    System.out.println("Connected");
    // -- Try to get hold of the default folder --
    folder = store.getDefaultFolder();
    if (folder == null) throw new Exception("No default folder");
    // -- ...and its INBOX --
    folder = folder.getFolder("INBOX");
    if (folder == null) throw new Exception("No POP3 INBOX");
    // -- Open the folder for read_write (to be able to delete message) --
    folder.open(Folder.READ_WRITE);
    // -- Get the message wrappers and process them --
    Message[] msgs = folder.getMessages();
    for (int msgNum = 0; msgNum < msgs.length; msgNum++){
    saveMessage(msgs[msgNum]);
    System.out.println("No more messages");
    return ("SUCCESS");
    catch (Exception ex){
    ex.printStackTrace();
    return ex.toString();
    finally{
    // -- Close down nicely --
    try{
    // close(true), to expunge deleted messages
    if (folder!=null) folder.close(true);
    if (store!=null) store.close();
    catch (Exception ex){
    //ex.printStackTrace();
    return ex.toString();
    Then create function receivemail.
    create or replace function receivemail(pop3_server in string,
    pop3_usr in string,
    pop3_pwd in string)
    return varchar2
    is language java name
    'ReceiveMail.Receive(java.lang.String,
    java.lang.String,
    java.lang.String) return String';
    And then trying to execute function receivemail, but I am getting following error.
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<Hotmail email address>@hotmail.com', 'Hotmail password');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......
    Edited by: Amol Karyakarte on 31-May-2012 7:27 AM

    Hello,
    I don't think this is the right forum, as this question seems to have nothing to do with the Oracle Forms tool.
    You'd better ask it in the database forum.
    Francois

  • Reading Inbox - javax.mail.MessagingException: Connect failed;

    I get an error message while trying to read emails by connecting to a company mailbox. The message is as follows:
    javax.mail.MessagingException: Connect failed;
    nested exception is:
         java.net.ConnectException: Connection refused: no further information
         boolean com.sun.mail.pop3.POP3Store.protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)
         void javax.mail.Service.connect(java.lang.String, int, java.lang.String, java.lang.String)
         void javax.mail.Service.connect(java.lang.String, java.lang.String, java.lang.String)
         void GetMessageExample.main(java.lang.String[])
    The code is very simple and as follows:
    import java.io.*;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class GetMessageExample {
    public static void main (String args[]) throws Exception {
    String host = "companyname.com";
    String username = "user";
    String password = "xxxx";
    try{
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getInstance(props, null);
    // Get the store
    Store store = session.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    BufferedReader reader = new BufferedReader (
    new InputStreamReader(System.in));
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    } catch (Exception e) {
    e.printStackTrace();
    I have a two part question:
    1. At home I am using a dial-up connection it works when I change the settings to an email account as provided by the local ISP.
    I have tried it with both "pop3" and "imap" in
    Store store = session.getStore("pop3");
    for the company email but it does not work.
    Is this a problem with company security? Maybe firewall/proxy error? If so how do I get around it?
    2. Also, when I am in the office (LAN used to connect to Internet) I cannot even get a connection to the ISP account - similar problem or different?
    Any thoughts and help most appreciated.
    Thanks in advance,
    Mark

    It could be that the mail server is not accepting connections from the machine you are on. Have you tried using Outlook Express or the Netscape email client to connect to the server/account from the machine that is getting the failure?

  • Javax.mail.NoSuchProviderException: No provider for ifs1

    Similar to the question found in William Troper's thread run on
    November 1. We had mail code working fine, changed some
    variables to incorporate a migratable build and have now lost
    our mail functionality.
    We have followed William's advice by renaming all of Sun's Mail
    classes in the ~\9ifs\settings\META-INF directory and still no
    joy.
    Does anyone have any ideas of what is causing a "No provider for
    ifs1" error message?
    Cheers,
    Susan

    Hi Scott,
    These (among other) items are in my CLASSPATH (printed out at
    runtime)
    /projects/intranet/lib/mail.jar:/app/oracle/product/9.0.1S/9ifs/s
    ettings/META-INF:
    Here is my stack. Also, the code is EXACLTY the same between
    what was working and what is now not. Thanks for looking in to
    this:
    javax.mail.NoSuchProviderException: No provider for ifs1
         at javax.mail.Session.getProvider(Session.java:249)
         at javax.mail.Session.getTransport(Session.java:442)
         at javax.mail.Session.getTransport(Session.java:423)
         at com.mim.intranet.utils.MessageFactory.sendMesg
    (MessageFactory.java:130)
         at
    com.mim.intranet.unittest.utils.MessagingUT.testValidMesg
    (MessagingUT.java:56)
         at java.lang.reflect.Method.invoke(Native Method)
         at junit.framework.TestCase.runTest(TestCase.java:166)
         at junit.framework.TestCase.runBare(TestCase.java:140)
         at junit.framework.TestResult$1.protect
    (TestResult.java:106)
         at junit.framework.TestResult.runProtected
    (TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:131)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.textui.TestRunner.doRun(TestRunner.java:74)
         at junit.textui.TestRunner.run(TestRunner.java:200)
         at com.mim.intranet.unittest.AllTests.main
    (AllTests.java:40)
    4887 [main] WARN com.mim.intranet.unittest.utils.MessagingUT -
    Sending Exception
    F
    Time: 4.898
    There was 1 failure:
    1) testValidMesg(com.mim.intranet.unittest.utils.MessagingUT)
    junit.framework.AssertionFailedError: Failed sending message :
    com.mim.intranet.exception.IntranetException: Failed sending
    message encountered unexpected exception
    Wrapped Exception is : javax.mail.NoSuchProviderException: No
    provider for ifs1
         at
    com.mim.intranet.unittest.utils.MessagingUT.testValidMesg
    (MessagingUT.java:63)
         at com.mim.intranet.unittest.AllTests.main
    (AllTests.java:40)
    FAILURES!!!
    Tests run: 1, Failures: 1, Errors: 0
    com.mim.intranet.exception.IntranetException: Failed sending
    message encountered unexpected exception
    Wrapped Exception is : javax.mail.NoSuchProviderException: No
    provider for ifs1
         at com.mim.intranet.utils.MessageFactory.sendMesg
    (MessageFactory.java:187)
         at
    com.mim.intranet.unittest.utils.MessagingUT.testValidMesg
    (MessagingUT.java:56)
         at java.lang.reflect.Method.invoke(Native Method)
         at junit.framework.TestCase.runTest(TestCase.java:166)
         at junit.framework.TestCase.runBare(TestCase.java:140)
         at junit.framework.TestResult$1.protect
    (TestResult.java:106)
         at junit.framework.TestResult.runProtected
    (TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:131)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.textui.TestRunner.doRun(TestRunner.java:74)
         at junit.textui.TestRunner.run(TestRunner.java:200)
         at com.mim.intranet.unittest.AllTests.main
    (AllTests.java:40)
    -----------------------------------------------------------------

  • Javax.mail.MessagingException: Not Connected

    Hi All,
    I am trying to read the message from pop.gmail.com using JavaMail API.I ma using POP3 protocol for it.
    But I got the following Exception
    javax.mail.MessagingException: Not Connected
    at com.sun.mail.pop3.POP3Store.checkConnected(POP3Store.java:279)
         at com.sun.mail.pop3.POP3Store.getFolder(POP3Store.java:261)
         at MailReceipt.connect(MailReceipt.java:97)
         at MailReceipt.mailRecieve(MailReceipt.java:62)
         at MailReceipt.main(MailReceipt.java:53)
    I got This Error at the line
    folder = store.getFolder("INBOX");
    in my program.
    Please Help me ion this regards.Thanks in Adnavce..
    Thanx & Regards
    Sandeep Verma

    Well, I've never used this API but it seems 100% clear what's wrong. And 5 seconds with Google has revealed that there's a method on that class which looks like it will address the issue.
    If you can't even read basic error messages, you should seriously question whether you should be programming.

  • Atg.service.email.EmailException: javax.mail.MessagingException:

    All, while sending email via web production application getting the following exception and it is intermittent as well, any quick pointers in cause/fix, please..
    ERROR [nucleusNamespace.atg.dynamo.service.EmailFormHandler] Failed to send meail message:Remember to set /atg/dynamo/service/SMTPEmail.emailHandlerHostName and /atg/dynamo/service/SMTPEmail.emailHandlerPort
    atg.service.email.EmailException: javax.mail.MessagingException: Exception reading response;
    nested exception is:
         java.net.SocketTimeoutException: Read timed out
         at atg.service.email.SMTPEmailSender.sendEmailMessage(SMTPEmailSender.java:907)
         at atg.service.email.SMTPEmailSender.sendEmailMessage(SMTPEmailSender.java:930)
         at atg.service.email.SMTPEmailSender.sendEmail(SMTPEmailSender.java:1009)
         at atg.service.email.SMTPEmailSender.sendEmailEvent(SMTPEmailSender.java:985)
         at atg.service.email.SMTPEmailSender.sendEmailMessage(SMTPEmailSender.java:522)
         at atg.service.email.EmailFormHandler.sendMail(EmailFormHandler.java:316)
         at atg.service.email.EmailFormHandler.handleSendEmail(EmailFormHandler.java:436)
         at sun.reflect.GeneratedMethodAccessor843.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:592)
         at atg.droplet.EventSender.sendEvent(EventSender.java:582)
         at atg.droplet.FormTag.doSendEvents(FormTag.java:791)
         at atg.droplet.FormTag.sendEvents(FormTag.java:640)
         at atg.droplet.DropletEventServlet.sendEvents(DropletEventServlet.java:523)
         at atg.droplet.DropletEventServlet.service(DropletEventServlet.java:550)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.sessionsaver.SessionSaverServlet.service(SessionSaverServlet.java:2442)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.order.CommerceCommandServlet.service(CommerceCommandServlet.java:128)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.promotion.PromotionServlet.service(PromotionServlet.java:191)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:602)

    Check the configuration of /atg/dynamo/service/SMTPEmail component and specify proper values for emailHandlerHostName, emailHandlerPort, username, password. By default emailHandlerHostName is configured to localhost and port is set to 25 which is default for SMTP. If you do not know these you can get these details from your mail administrator who has setup your mail-id. You would also need to specify the username and password if your administrator has not allowed for making anonymous connection to the mail server.

  • Javax.mail.internet.AddressException how to escape double quote

    When I try and parse the following internetaddress:
    InternetAddress.parse("sevsev o'first sevsev o\"last <[email protected]>")I get the following stacktrace:
    Tomcat Log [(CKY50) 2006/09/27 15:26:29.217]: 4 Email.setReplyToAddresses() javax.mail.internet.AddressException: Missing '"' in string ``sevsev o'first sevsev o"last <[email protected]>'' at position 52
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:676)
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:529)
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:506)How do I escape the double quote? Thanks in advance!

    Thanks for the quick response, I tried that and got the same stacktrace:
    Tomcat Log [(3YVJS) 2006/09/27 15:44:38.554]: 4 Email.setReplyToAddresses() javax.mail.internet.AddressException: Missing '"' in string ``sevsev o'first sevsev o"last <[email protected]>'' at position 52
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:676)
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:529)
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:506)

  • Random javax.mail.FolderNotFoundException

    Hi all,
    we have a java application hosted on Win 2000 wich is using javamail api to interact with MS Exchange 2003. Basically is getting folders and iterating trough them.
    From time to time we get an error about javax.mail.FolderNotFoundException.
    This is happening really randomly and not on the same folder, the ms event viewer doesn't say so much, and the application has basic log4j error with no stack trace, only the getMessage().
    My question is, do you know of any existing bug between the three systems wich could cause such error ?
    Where do you think I should start to solve the problem ? Network ? Java ?
    thanks in advance...

    Turn on session debugging and examine the
    protocol trace. See the JavaMail FAQ.

  • Error: javax.mail.SendFailedException

    Hi all,
    I have a requirement to send a mail on click of a button. I have written a simple java code using java mail API. But while running the application i am getting
    javax.mail.SendFailedException: Sending failed;  nested exception is: javax.mail.SendFailedException: Invalid Addresses;  nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
    If i run the java code as a standalone java application everything is fine. Only in webdynpro application i am getting the above mentioned error.
    My question is do we have to configure any settings in the WAS. If so, can somebody give me a detailed answer how to do the configuration.
    Thanks and Regards,
    Rathna

    I stopped the Antivirus service and checked the application but it doesn't help.
    Here is the code. But the code is working fine.
    // Get system properties
    Properties props = new Properties();
    // Setup mail server
    props.put("mail.pop3.host","myserver");
    props.put("mail.pop3.auth","true");
    Authentication auth = new Authentication("[email protected]","abcd");
                   Session session = Session.getInstance(props,auth);
                   Store store = session.getStore("pop3");
                   store.connect("myserver","[email protected]","abcd");
                   System.out.println("Connected");
                   MimeMessage message =  new MimeMessage(session);
                   message.setFrom(new InternetAddress("[email protected]"));
                   message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress("[email protected]"));
                   message.setSubject("Hello JavaMail Attachment");
                   // create the message part
                   MimeBodyPart messageBodyPart =  new MimeBodyPart();
                   //fill message
                   messageBodyPart.setText("Hi");
                   Multipart multipart = new MimeMultipart();
                   multipart.addBodyPart(messageBodyPart);
                   // Part two is attachment
                   messageBodyPart = new MimeBodyPart();
                   String fileAttachment="D:\Message.txt";
                   DataSource source =  new FileDataSource(fileAttachment);
                   messageBodyPart.setDataHandler(new DataHandler(source));
                   messageBodyPart.setFileName(fileAttachment);
                   multipart.addBodyPart(messageBodyPart);
                   // Put parts in message
                   message.setContent(multipart);
                                  // Send the message
                   javax.mail.Transport.send(message);
                   System.out.println("Mail sent successfully");
                   store.close();

  • Javax.mail.mailexception while am trying to send the mail

    Hi.
    Am trying to send a mail from ADF Application am using SMTP Server to send the mail
    I have added javamail.jar in my libraries
    This is the code am using to send
        public String send() {
            // Add event code here...
            String to;
            to = new String();
            String host = "localhost";
            String from = "[email protected]";
            Properties properties = System.getProperties();
            properties.setProperty("mail.smtp.host", host);
            Session session = Session.getDefaultInstance(properties);
            try{
                MimeMessage message = new MimeMessage (session);
                message.setFrom(new InternetAddress(from));
                message.addRecipient(Message.RecipientType.TO,new InternetAddress("to"));
                message.setSubject(subj);
                message.setText(body);
                Transport.send(message);
                System.out.println ("Sent Message Successfully");
            catch(MessagingException max){
                max.printStackTrace();
            return null;
        }Am getting the exception as below
    javax.mail.MessagingException: [EOF]
         at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1481)
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1512)
         at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1321)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:637)
         at javax.mail.Transport.send0(Transport.java:189)
         at javax.mail.Transport.send(Transport.java:118)
         at view.SendMail.send(SendMail.java:78)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
    Could any one pls help me?
    regards,
    Prasad K T.

    This question is better asked in a java forum or JavaMail forum {forum:id=975}
    Timo

  • Problems sending email using javax.mail.*

    I need to send an email from an application I am working on. I am using the features of the javax.mail package to do so. In looking at the code I am unsure why this is not working. This is my first time using this package so it might be something silly I am missing so any of your thoughts are appreciated. The code is as follows:
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class EmailTester {
         public static void main(String[] args) {
              try {
                   //Set the smtp address
                   Properties props = new Properties();
                   props.put("mail.smtp.host", args[0] );
                   // get the default Session
                   Session session = Session.getDefaultInstance(props, null);
                   session.setDebug(true);
                   // create a message for this session
                   Message msg = new MimeMessage(session);
                   // set the from and to address
                   InternetAddress from =
                        new InternetAddress( args[1] );
                   InternetAddress[] to = new InternetAddress[1];
                   to[0] = new InternetAddress( args[2] );
                   msg.setFrom(from);
                   msg.setRecipients(Message.RecipientType.TO, to);
                   // set the subject and content type
                   msg.setSubject("subject");
                   msg.setContent("this is my test email", "text/plain");
                   // send the email
                   Transport.send(msg);
              catch (MessagingException me) {

    I have an EMail class that I use at:
    http://www.discoverteenergy.com/files/EMail.java
    Feel free to use it or compare against your code to see what is different.

  • Problem with recognizing javax.mail.* class ?

    Hi Folks,
    I am new to JavaMail usage on a standalone java program. I did write a java program to send a mail. The problem is it is not recognizing the javax.mail.* class, though i added on the classpath. I too added mail.jar file in the c:\program files\java\jdk1.5.0_16\lib and added the reference same to the classpath and still it is not recognizing. Do i miss something? help me out guys.
    Regards,
    jaisuryah

    Hi Shannon,
    I hope the configuration i did is well. Yah am running the Java from the command line and i dont know why importing the package of javax.mail.* classes are not recognizing. I did unzipped the zip file and placed all the JAR files to lib folder of my installed JDK and referenced the JDK to classpath in environment variable also.
    Regards,
    Jaisuryah

  • Package javax.mail does not exist (Still having trouble)

    Good Morning
    I know that there are several posts regarding issues with javamail. I have viewed them for the past hour. While several of them address my issue I have been unable to locate a solution.
    Bare with me please, I am making this post very thorough. The other threads I have read are frusterating because the problems people tend to post are not clear.
    I am trying to run "msgsend" which is a provided demo of javamail-1.4 using command prompt (start - run - cmd) with the javac command.
    The output below is directly pasted from command prompt and written in bold.
    C:\download\javamail-1.4\demo>javac msgsend.java
    C:\download\javamail-1.4\demo>javac msgsend.java
    msgsend.java:44: package javax.mail does not exist
    import javax.mail.*;
    ^
    msgsend.java:45: package javax.mail.internet does not exist
    import javax.mail.internet.*;
    ^
    msgsend.java:140: cannot find symbol
    symbol : class Session
    location: class msgsend
    Session session = Session.getInstance(props, null);
    ^
    msgsend.java:140: cannot find symbol
    symbol : variable Session
    location: class msgsend
    Session session = Session.getInstance(props, null);
    ^
    msgsend.java:145: cannot find symbol
    symbol : class Message
    location: class msgsend
    Message msg = new MimeMessage(session);
    ^
    msgsend.java:145: cannot find symbol
    symbol : class MimeMessage
    location: class msgsend
    Message msg = new MimeMessage(session);
    ^
    msgsend.java:147: cannot find symbol
    symbol : class InternetAddress
    location: class msgsend
    msg.setFrom(new InternetAddress(from));
    ^
    msgsend.java:151: package Message does not exist
    msg.setRecipients(Message.RecipientType.TO,
    ^
    msgsend.java:152: cannot find symbol
    symbol : variable InternetAddress
    location: class msgsend
    InternetAddress.parse(to,
    ^
    msgsend.java:154: package Message does not exist
    msg.setRecipients(Message.RecipientType.CC,
    ^
    msgsend.java:155: cannot find symbol
    symbol : variable InternetAddress
    location: class msgsend
    InternetAddress.parse(cc,
    ^
    msgsend.java:157: package Message does not exist
    msg.setRecipients(Message.RecipientType.BCC,
    ^
    msgsend.java:158: cannot find symbol
    symbol : variable InternetAddress
    location: class msgsend
    InternetAddress.parse(bcc,
    ^
    msgsend.java:167: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp1 = new MimeBodyPart();
    ^
    msgsend.java:167: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp1 = new MimeBodyPart();
    ^
    msgsend.java:169: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp2 = new MimeBodyPart();
    ^
    msgsend.java:169: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp2 = new MimeBodyPart();
    ^
    msgsend.java:171: cannot find symbol
    symbol : class MimeMultipart
    location: class msgsend
    MimeMultipart mp = new MimeMultipart();
    ^
    msgsend.java:171: cannot find symbol
    symbol : class MimeMultipart
    location: class msgsend
    MimeMultipart mp = new MimeMultipart();
    ^
    msgsend.java:185: cannot find symbol
    symbol : variable Transport
    location: class msgsend
    Transport.send(msg);
    ^
    msgsend.java:193: cannot find symbol
    symbol : class Store
    location: class msgsend
    Store store = null;
    ^
    msgsend.java:195: cannot find symbol
    symbol : class URLName
    location: class msgsend
    URLName urln = new URLName(url);
    ^
    msgsend.java:195: cannot find symbol
    symbol : class URLName
    location: class msgsend
    URLName urln = new URLName(url);
    ^
    msgsend.java:212: cannot find symbol
    symbol : class Folder
    location: class msgsend
    Folder folder = store.getFolder(record);
    ^
    msgsend.java:218: cannot find symbol
    symbol : variable Folder
    location: class msgsend
    folder.create(Folder.HOLDS_MESSAGES);
    ^
    msgsend.java:220: cannot find symbol
    symbol : class Message
    location: class msgsend
    Message[] msgs = new Message[1];
    ^
    msgsend.java:220: cannot find symbol
    symbol : class Message
    location: class msgsend
    Message[] msgs = new Message[1];
    27 errors
    Here are the methods I have tried...
    1. Make sure you have most current version of Java
    2. Reinstall Java
    3. Attempt to compile in an IDE (Attempted in Eclipse 3.2)
    4. Set class path
    Some sources suggest "CLASSPATH" some suggest "CLASS PATH" as the variable name. I have tried both.
    Below is what the classpath looks like in bold.
    Variable Name: CLASS PATH
    Variable value: c:\download\javamail-1.4\mail.jar;C:\download\jaf-1.1\activation.jar;.
    I have double checked all folder names and copy pasted all entries to eliminate typos. Javamail-1.4 and jaf-1.1 are both located in c:\download which is the same location Class Path points to.
    Thank you very much for your input and effort. I can imagine how frusterating it is responding to 20million javamail posts :) (that may be a bit of an overstatement!)
    Thank you again!
    Irbi
    Message was edited by:
    irbi
    Message was edited by:
    irbi

    Yes - I have read that part of the README and did exactly as it has said in a previous attempt. I should have mentioned that here I'm sorry :)
    I moved the .jar files into the download folder and set the classpath exactly as the readme shows.
    When I do that the msgsend.java compiles correctly but it still does not run.
    Below is what happens.
    C:\download\javamail-1.4\demo>set CLASSPATH=%CLASSPATH%;c:\download\javamail-1.4
    \mail.jar;%CLASSPATH%;c:\download\jaf-1.1\activation.jar.
    C:\download\javamail-1.4\demo>javac msgsend.java
    C:\download\javamail-1.4\demo>java msgsend.java
    Exception in thread "main" java.lang.NoClassDefFoundError: msgsend/java
    C:\download\javamail-1.4\demo>
    I have tried fixing this error as well via forums and FAQs but it seems to be the most generic error.
    One suggestion was to clear your classpath. I tried this with a test hello world program which was giving the same error - "NoClassDefFoundError". By clearing the classpath I was able to get the hello world program to run without this error. But I can't just clear the classpath in this instance because it needs to point to mail.jar and activation.jar for the program to compile.
    Thanks again for all of your efforts. You are more appreciated than you know.

  • Exception in thread "main" javax.mail.NoSuchProviderException: invalid prov

    HI,
    I am trying to read mails from my inbox i amgetting the ErrorC:\javamail>java
    Readmail
    Exception in thread "main" javax.mail.NoSuchProviderException: No provider for IMAP
            at javax.mail.Session.getProvider(Session.java:455)
            at javax.mail.Session.getStore(Session.java:530)
            at javax.mail.Session.getStore(Session.java:510)
            at Readmail.main(Readmail.java:24)My Code is    {
    String host = "hostname";
    String username = "user";
    String password = "password";
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getDefaultInstance(props,null);
    // Get the store
    Store store = session.getStore("IMAP");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("Inbox");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++)
       System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    I have also tried POP3 and MIME and SMTP
    Can anyone help me Thanks

    hi bshannon,
    I am getting the same error for others but for pop3 the error is as below
    Exception in thread "main" javax.mail.MessagingException: Connect failed;
      nested exception is:
            java.net.ConnectException: Connection refused: connect
            at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)
            at javax.mail.Service.connect(Service.java:275)
            at javax.mail.Service.connect(Service.java:156)
            at Readmail.main(Readmail.java:25)
    Caused by: java.net.ConnectException: Connection refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
            at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
            at java.net.Socket.connect(Socket.java:452)
            at java.net.Socket.connect(Socket.java:402)
            at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
            at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
            at com.sun.mail.pop3.Protocol.<init>(Protocol.java:81)
            at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
            at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
            ... 3 more

Maybe you are looking for

  • After installing the latest itunes update most of my music cannot be located. A box pops up and says the song cannot be found. What can I do?

    I installed the latest itunes update and now I can't play most of my songs. A box pops up that says it cannot be located and asks me if I want to locate it and when I click on Yes it gives me all my files on the computer (dropdown box) and I don't kn

  • Photon Focus MV-D1024E-160-CL-12 Camera frame rate problem.

    Hi, I have a photon Focus MV-D1024E-160-CL-12 camera connected with a PCI2-1429 board. I trigger my camera externally using a NI-DAQ and an I/O board to the camera. I am having a problem with the frame rate of my camera. In the manual it says that th

  • WRT160NL DLNA Media Server Unstable (Twonky Media)

    I have an NTFS formatted USB disk drive (Western Digital My Passport Essential Black 320 GB WDBAAA3200ABK) attached to the WRT160NL wireless router (Firmware Version 1.0.02), and I have video, picture and music files on the USB disk drive in three fo

  • Ctrl + 0 not filling up window size

    Historically, when I pressed ctrl + 0 in Photoshop, an image came to fill up the available window space within Photoshop. Now, ctrl + 0 causes the image to become roughly 3 inches tall. If the image is twice as tall as it is wide, it becomes roughly

  • FLex Data service

    I run into problem when i create Flex Data Service project. I get error when i try to compile my code "Invalid byte 1 of 1-byte UTF-8 sequence" Doesnt say anything more of what is going on. I tried it both on Vista and XP but sometimes project runs a