This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Email Host Configuration Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Email Host Configuration Problem" Watch "Email Host Configuration Problem" New topic
Author

Email Host Configuration Problem

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
I am developing a Java based Web application which has to send an email to the user. In my home, I have an outlook express and I don't have any mail server.
Suppose i want to send an email to different user like a@yahoo.com, b@rediffmail how can I configure the host and its user name and password.

Whether i need to install any personal mail server in my local machine and I have to use my local machine host for this purpose. If it is, what personal open source mail server is available and how to configure it.

If it is not required to install any mail server in my local machine, how can I configure the host and username and password. Since I can't able to get the Yahoo Mail Server Host and it's username and password. Please through some light on it.

But I have configured my outlook express with POP3 Yahoo mail Server. So whatever, mail I am getting in yahoo mail server will be accessed through my outlokk express.


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
This JavaMail tutorial has plenty of examples on how to send and receive emails using Java, including using authentication.


Ping & DNS - updated with new look and Ping home screen widget
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
As far as I goolged in net for sending and receiing mail I have the following assumption.
For sending the email we have to use SMTP. For example If I want to send an email to the user like aa@yahoo.com, then I have to use the SMTP Server/Host name of the yahoo mail server. Even If I am using the Yahoo Host name, it has to accept it. Since it may consider the incoming mail can be a spam.
Though, If I am having a free account with Yahoo, I have heard that it won't allow to talk with their(Yahoo) SMTP server. For this purpose we need to have a paid in yahoo account.

My Doubts:

1. I don't have a paid in yahoo mail account.
2. I want to send a mail to the user which can be a different mail account like gmail,hotmail (ex: ss@gmail.com. dd@rediffmail.com).
In this case how can i use the host name? which host name I have to give yahoo,gmail..?
I have used the below program for sending the mail, but I am getting the error:



ERROR:
=========


Why I am getting the AuthenticationFailedException? How to resolve it? Whether I can abvle to send to only one type of host like either yahoo or gmail or rediff?
Why I am getting the FileNotFoundException?



What these files will contains? Whether I have to place this files in the required locations?

[ November 28, 2007: Message edited by: Micheal John ]
[ November 28, 2007: Message edited by: Ulf Dittmer ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
The files are not important, but providing authentication is. That's why I suggested to consult the code examples in the page I linked to. It shows how to do all that.

But it still isn't going to work, because -as you correctly mention- Yahoo doesn't allow SMTP access for its free acounts.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
what will be work around for this? I cannot able to send mail to any host?Whether yahoo only not allowing to access its SMTP server for its free mail account or gmail, hotmail, rediffmail also remain the same(they are also not allowing?) Is there any mail server which also to access their SMTP server. My purpose of accessing SMTP server is to send an mail to user. If any, I will create a account with them?

I just want to test my java program to send a mail to the user. I am developing a product, which later don't have this issue. Since the company which is going to use this product will have their own mail srver and mail wil be send to the user in that company only. So it don't have a problem.

Suppose I am doing this product for ABC copmany, they will have the domain and all thy user belongs to the company will have the mail id like aa@abc.com,d@abc.com. so their mail server will send the mail.

Right now I don't have any set up and how can I test it.please throw some light on it. Please give some work around for this.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
You can either use your company's email server -which presumably allows this-, or run an email server like James -which is very easy to set up- on your local machine.
Mike Thomson
Ranch Hand

Joined: Nov 07, 2007
Posts: 115
Thanks..
Using Configuring Apache James in my machine, I can able to send mail to any user/ any restriction is there?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Using Configuring Apache James in my machine, I can able to send mail to any user?

Yes.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
I have configure Apache James with my system successfully and I have create a user and used a program to send a mail to the user. In this case I have used domain as localhost. Now for domain can I use yahoo.com, gmail.com. If it not possible I would like to configure my outlook express for the localhost domain.

For example:
I will create the user like abc@sand.com, def@sand.com..... using the Apache james. Then I am trying to configure outlook express and while configuring, it asking for POP3 and SMTP setting. What i have to give in this case? If it configured I will send the mail from my program so that I can able to get the mail in the outlook express in the offline. Am I right or it need to have a internet connection. I know in case of yahoo.com, gmail.com we need internet..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
You'll always need an internet connection to send email; how else would it get to the recipients? Some mail servers may cache mails if the connection is currently down; I'm not sure if James does that.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
What I thought was even if we have Apache mail server how the Yahoo SMTP server will accept to access it? So I thought using James we can create a new user and password with some dummy domains and we can configure the outlook express account to receive the mail from the program locally without any net connection.
No Problem.. I somewhere misunderstood. so do you mean to say that I can configure the James xml file to give Yahoo domain. I have a free yahoo email account and can I use that?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
so do you mean to say that I can configure the James xml file to give Yahoo domain.

No. Yahoo accounts are serviced by Yahoo's email servers. In any case it's not a good idea to configure a mail server on a machine that (in all likelihood) is not reachable from the net via SMTP because of firewall restrictions, and which is not always running.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
so I cannot send mail to yahoo/gmail using james server.
What I want is just to send an email from a java program and I should able to see the mail which I had sent thru java pgm in the outlook express using apache james or by others. How can I do it? How to configure the outlook express for it. Since you are advising that it not possible to send it to yahoo/gmail free email user accounts
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
so I cannot send mail to yahoo/gmail using james server.

Not if the objective is to do this without a network connection.

What I want is just to send an email from a java program and I should able to see the mail which I had sent thru java pgm in the outlook express using apache james or by others.

In that case, add a new account in Outlook that uses "localhost" as its server for both SMTP and POP3. This account needs to corresond to a James account that you need to set up first. Then you can use Outlook to send and receive mail through James.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
Thanks very much for your reply and so if I have internet connection, then I can able to send to yahoo/gmail also. How to configure the config.xml in James server for yahoo mail server.
In domain I have given yahoo.com and rest of the things I have the confusion. If my machine is connected to internet and I am getting the DNS Server name and given that too in config xml file. That's enough or we need to do any other configurations
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
How to configure the config.xml in James server for yahoo mail server.
In domain I have given yahoo.com and rest of the things I have the confusion.


I think you're a bit confused about how email works. There is nothing to configure for sending email to any domain. Just use the @yahoo.com email address in the JavaMail client code, have it connect to James, and it will deliver the email to your Yahoo account. Since Yahoo is not part of your local network, you will need an internet connection for that, though (which you said before you wanted to avoid). As mentioned above, Yahoo mail can't be handled locally in the sense that it can be delivered to or received from a local mail server; all you can can do is send it locally.
Sanjay Mistry
Greenhorn

Joined: Oct 30, 2005
Posts: 17
Search for topic "Connect to SMTP server", I have submitted code to send email through gmail and it works.

Regards
Sanjay Mistry


Java Rules....<br />SCJP 1.4, SCJD 1.4, busy with SCJWCD, after that SCBCD...
Ratan Kumar Yadav
Greenhorn

Joined: May 02, 2008
Posts: 6

Ulf

Thanks for the precise explantion
Even I am facing the same issue as Micheal...

Installed JAMES ,added a user to it say ratan@localhost
but I am not able to send mails to gmail account.

A step by step approach will be helpful...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Email Host Configuration Problem
 
Similar Threads
Proble in sending email thru java program
to call outlook express mail message window
how to call outlook express mail message window
How to configure hmail Server and Microsoft Outlook for testing Java Mail applications
My Application is not sending mail to external servers