SMTP server setting for Java Mail

Discussion in 'Java' started by durnylka@gazeta.pl, Nov 8, 2006.

  1. Guest

    Hi,

    I have a little knowledge of java and have no more ideas how to solve
    my problem. Can you please have a look at it?

    One of my applications is started via Java Web Start on a client PC.
    This application has a possibility to send e-mails. Unfortunately
    sending e-mails fails with the following log:

    [...]
    [10/26/06 13:15:01:413 CEST] 25cc04c4 SystemOut O * HOSTNAME =
    linux.client.net
    [10/26/06 13:15:01:413 CEST] 25cc04c4 SystemOut O * Matching domain
    for linux.client.net
    [10/26/06 13:15:02:096 CEST] 25cc04c4 SystemOut O DEBUG:
    mail.smtp.class property exists and points to
    com.sun.mail.smtp.SMTPTransport
    [10/26/06 13:15:02:098 CEST] 25cc04c4 SystemOut O DEBUG SMTP:
    useEhlo true, useAuth false
    [10/26/06 13:15:02:098 CEST] 25cc04c4 SystemOut O
    DEBUG: NOCNOKI trying to connect to host "SMTPHOST.network.com", port
    25

    [10/26/06 13:15:02:098 CEST] 25cc04c4 WebGroup I SRVE0180I:
    [ReportBrowser] [/ReportBrowser] [Servlet.LOG]: WARNING:
    ReportJob.localExcecute(): Sending mail message failed for report (omc,
    1019482) in REPORTER receivers: Reason:
    javax.mail.SendFailedException Message: Sending failed;
    nested exception is:
    javax.mail.MessagingException: Unknown SMTP host:
    SMTPHOST.network.com;
    nested exception is:
    java.net.UnknownHostException: SMTPHOST.network.com

    I can't find where SMTPHOST.network.com is set. Is it possible to
    change this value? How to do it? I don't have source code of the
    application in question but I hope that there is a way to set SMTP
    server hostname without modifying the source code.

    FYI: I edited the hostnames in the log.

    Can you please help me?
    , Nov 8, 2006
    #1
    1. Advertising

  2. Try this:

    Properties properties = System.getProperties();
    properties.put("mail.smtp.host", "yoursmtpserver");
    Session mailSession = Session.getDefaultInstance(properties, null);
    Message email = new MimeMessage(mailSession);
    email.setFrom(..);
    email.setRecipients(..)
    email.setSubject(..);
    email.setText(..);
    Transport.send(email);

    Check out javadocs on the above API usage for more information..

    -cheers,
    Manish
    Manish Pandit, Nov 8, 2006
    #2
    1. Advertising

  3. Guest

    Manish Pandit napisal(a):
    > Try this:
    >
    > Properties properties = System.getProperties();
    > properties.put("mail.smtp.host", "yoursmtpserver");
    > Session mailSession = Session.getDefaultInstance(properties, null);
    > Message email = new MimeMessage(mailSession);
    > email.setFrom(..);
    > email.setRecipients(..)
    > email.setSubject(..);
    > email.setText(..);
    > Transport.send(email);
    >
    > Check out javadocs on the above API usage for more information..
    >
    > -cheers,
    > Manish


    OK, thanks. But how to give properties to the application? Is it
    possible to create a config file with the properties and force the
    application to read it during the startup? I don't know it...:-/
    , Nov 8, 2006
    #3

  4. > OK, thanks. But how to give properties to the application? Is it
    > possible to create a config file with the properties and force the
    > application to read it during the startup? I don't know it...:-/


    Yes, it is possible. Some (easy) ways are :

    -By having a properties file on the disk with name=value formatted
    properties
    -Using -D<name>=<value> option for the jvm when you run your program.

    -cheers,
    Manish
    Manish Pandit, Nov 8, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Curt_C [MVP]
    Replies:
    5
    Views:
    354
    Karim
    May 19, 2004
  2. Replies:
    3
    Views:
    1,048
    Roedy Green
    Jan 24, 2006
  3. pk
    Replies:
    3
    Views:
    787
    Roedy Green
    Feb 13, 2006
  4. Alex Hunsley
    Replies:
    4
    Views:
    3,405
    Tim Williams (gmail)
    Jun 29, 2004
  5. Raaijmakers, Vincent \(GE Infrastructure\)

    RE: sending of mail (smtp) - connection refused - but smtp serveris running!

    Raaijmakers, Vincent \(GE Infrastructure\), Jun 29, 2004, in forum: Python
    Replies:
    0
    Views:
    860
    Raaijmakers, Vincent \(GE Infrastructure\)
    Jun 29, 2004
Loading...

Share This Page