Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2007, 06:52 AM
Authorized User
 
Join Date: Jun 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ajit
Default Mail(SMTP)

Hi I have an application that sends mail to few addresses in an interval. I have the sample code as below,
Code:
 Properties prop = System.getProperties();
 prop.setProperty("mail.smtp.host",<SMTP Mail Server Name>);
 Session session = Session.getInstance(props);
 MimeMessage message = new MimeMessage(session);
 message.setFrom(new InternetAddress("ajith_sowkoor@yahoo.com"));
 message.addRecipient(Message.RecipientType.TO,new InternetAddress("ajithsowkoor@gmail.com"));
 message.setSubject("test");
 message.setText("Test Mail");
 Transport.send(message);
 With in my LAN there is no problem, here I given IP address of the system that runs a Mailer daemon as mail sever name. I am getting mails in outlook express in my LAN. But when I give Our SMTP server name that is used in for internet (Provieded by a service provider who manage our site), I am not finding any error or exceptions but, I could not find mails in the mail box.

Ajit
__________________
Ajit
 
Old May 1st, 2007, 11:37 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

Usually SMTP servers need authentication, you have to provide the username and password to use SMTP server in java mail.
First you've to implement javax.mail.Authenticator class and override getPasswordAuthentication() method which will return PasswordAuthentication object[just use new PasswordAuthentication(smtp_username, smtp_password)].
You've to pass this PasswordAuthentication object to the Session.getInstanace(properties, authentication object) method as second parameter.

Hope thats helpful.

Regards,
Rakesh
 
Old October 24th, 2007, 12:01 AM
Authorized User
 
Join Date: Jun 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ajit
Default

 ThanX Rakesh


Ajit





Similar Threads
Thread Thread Starter Forum Replies Last Post
SMTP mail problem akhilesh_g ASP.NET 2.0 Professional 0 August 28th, 2008 01:31 AM
SMTP Authentication and mail() lemonadeX Pro PHP 1 July 31st, 2007 10:06 AM
Send Mail without SMTP angshujit ASP.NET 2.0 Basics 2 February 19th, 2007 10:04 AM
Send e-mail in smtp Samikaraeen Pro VB.NET 2002/2003 1 February 14th, 2005 12:01 PM
SMTP for mail() petercch Pro PHP 1 July 25th, 2003 06:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.