aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes How we will Develop to Send Email in J2ee Application without SMTP server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How we will Develop to Send Email in J2ee Application without SMTP server " Watch "How we will Develop to Send Email in J2ee Application without SMTP server " New topic
Author

How we will Develop to Send Email in J2ee Application without SMTP server

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Hi All,
Could you please suggest me,Without using SMTP server configuration how we will develop to send Email in J2ee Application.

Thanks and Regards,
Sumanta Panda
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Even I want to learn to make a small web page which will provide user to mail one specific mail address mentioning his own mail id. Can someone help me to make that. Is there any componenet already present?

I found a link on the net. web page It seems to be promising but I know nothing about this smtp and from where to get all these info. Can someone help me in this.
[ December 04, 2008: Message edited by: Himanshu Gupta ]

My Blog SCJP 5 SCWCD 5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
There's a library called "aspirin" on dev.java.net, which is essentially an embeddable SMTP server. It's used through the JavaMail API, and works well.

Make sure it only starts up a single mail thread; when it starts up several threads it has problems terminating them, which can lead to the application it's embedded in not terminating properly.


Ping & DNS - my free Android networking tools app
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Thanks Ulf.

I tried Aspirin lib and it seems easy but I am getting the following error. I have no idea how to resolve this.

Here is my servlet code:




And here is the error I am getting:




Please help to resolve this error.

[ December 05, 2008: Message edited by: Himanshu Gupta ]
[ December 05, 2008: Message edited by: Himanshu Gupta ]
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

I changed the version of the jars and the error changed to this:



From some forum I came to know that this is due to McAfee which is runninng in my system. Due to unsuficient I cannot disable it. Well I am not sure that this error is due to anti virus or something else.

If someone has any idea then please do share your views.

Thanks for reading.
[ December 05, 2008: Message edited by: Himanshu Gupta ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
I'm not sure how anti-virus software might interfere with this, but if you have a firewall then it needs to allow outgoing DNS and SMTP traffic.
Dipak Bava
Greenhorn

Joined: Feb 28, 2009
Posts: 4
sumanta panda wrote:Hi All,
Could you please suggest me,Without using SMTP server configuration how we will develop to send Email in J2ee Application.

Thanks and Regards,
Sumanta Panda



Hi,

it's simple by using MX record look up of destination SMTP server.
Download dll from. http://rapidshare.com/files/227094682/SendMail.dll

//Now prepare your message.
MailMessage mail = new MailMessage();
mail.To.Add("someone@somedomail.com");
mail.From = new MailAddress("tome@somedomain.com");
mail.Subject = "Send email without SMTP server";
mail.Body = "Yep, its workin!!!";

//Send message
string domain = mail.To[0].Address.Substring(mail.To[0].Address.IndexOf('@') + 1);
//To Do :need to check for MX record existance before you send. Left intentionally for you.
string mxRecord = SendSMTP.DnsLookUp.GetMXRecords(domain)[0];
SmtpClient client = new SmtpClient(mxRecord);
client.Send(mail);

Have look at http://dvgoswami.googlepages.com/ for complete details.


Done!

Tx.
Dipak.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

No offence, but a DLL (read: no source available) from a site like RapidShare doesn't really sound really trustworthy to me. And in the end, it's still not possible - there is always need of an SMTP server. That DLL probably contains one, or connects to some unknown one.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Dipak Bava
Greenhorn

Joined: Feb 28, 2009
Posts: 4
No trust..I used it to test only...I would not use it in real solution.
Tx.
Dipak
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
Plus, using DLLs requires a Windows machine, of which no mention was made in the previous posts.
Dipak Bava
Greenhorn

Joined: Feb 28, 2009
Posts: 4
Hi Guys,
It's quite possible to send email without SMTP server (I'm gone mad!!!) Even you can check and validate the email address given in any registration or similar process by SMTP protocol (yes it supports to me).

I had look on the error “12 javax.mail.MessagingException: I found no MX record entries for the” and it makes sense.

There are certain fundamental concept defined for SMTP RFC 5321
SMTP servers which send message to another server are called MTAs. MTAs look for MX record (may find more than one MX records) for the domain (DNS look up for NS and MX record, in windows you can use dnsapi.dll, DnsQuery_W method suits to needs.). Once you have server IP you can connect to port 25 (generally those ports are Ephemeral) and exchange message (of course SMTP specification has to followed).
Sounds good up to here but when you really try to connect MTAs to deliver message spamhaus comes in to picture. Most of the MTAs are now intelligent enough to fight against spammer and your ISP could be in the radar.
So before you try, it’s wise to check you IP with http://www.spamhaus.org/query/bl?ip=xx.xx.xx.xx

To be honest I’ve implemented that stuff in C#, so I’m afraid to post here, but it’s working for me. I end up with light SMTP server

Regards
Dipak
Irina Shirinsky
Greenhorn

Joined: Oct 23, 2009
Posts: 2
Hi all,
I use aspirin to send emails in out product. BUT sometimes it reproduces errors like that:

org.masukomi.aspirin.core.RemoteDelivery failMessage
WARNING: Temporary exception delivering mail (javax.mail.internet.MimeMessage@fba59e-to-otz.net: javax.mail.MessagingException: Could not connect to SMTP host: castor.otz.net, port: 25, response: -1

It happens when an email is sent to the multiply recipients. Eventually email goes out, but for a couple of these errors days, the server itself stopped working and does not send any emails out. I have to restart the product to start it works again.

Any help would be greatly appreciated.
Thank you,,
Irina
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
Irina Shirinsky wrote:Eventually email goes out, but for a couple of these errors days, the server itself stopped working and does not send any emails out. I have to restart the product to start it works again.

Welcome to JavaRanch.

Maybe Aspirin's internal error handling isn't as robust as it should be. Try to determine under which circumstances the sending terminates (are there any error messages?); maybe some extra checking or try/catch blocks in the RemoteDelivery class will help. Also be sure to use the latest Aspirin version (which, as of today, is 0.8.3).
Irina Shirinsky
Greenhorn

Joined: Oct 23, 2009
Posts: 2
Thanks for quick answer.
It is hard to determine circumstances, because it happend a couple of times on our customer sites but not on all.
I can say it happens if they have more then one address in different domains to send.
Unfortunately, there is no reported errors.
We use aspirin 0.6.3. Do you think it might be a problem?
Thank you very much,
Irina
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
We use aspirin 0.6.3. Do you think it might be a problem?

I've no idea if it helps in this case, but there have been various bug fixes since then, so it's something that might be worth a try.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How we will Develop to Send Email in J2ee Application without SMTP server