Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

SMTP server setting for Java Mail

Thread view: 
durnylka@gazeta.pl - 08 Nov 2006 09:28 GMT
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: name.surname@client.net 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?
Manish Pandit - 08 Nov 2006 09:44 GMT
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
durnylka@gazeta.pl - 08 Nov 2006 09:48 GMT
Manish Pandit napisal(a):
> Try this:
>
[quoted text clipped - 12 lines]
> -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...:-/
Manish Pandit - 08 Nov 2006 10:08 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.