• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.mail without specifying SMTP server

 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to write code to send email without trying to specify the SMTP server.
I have tried DOS nslookup without success. On the other hand, it may be impossible and the SMTP server is not in the computer, I just don't know.

Your help will be greatly appreciated,

Alejandro Barrero
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to run your own mail server for testing, you can use the James open source Java server. I have used it for years, it doesn't require a whole lot of memory to run.

Bill
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill. James definitely offers a solution; I just downloaded it and will start examining it in short detail. However, my code will be in an application that I will distribute; if I use mail, I will have to include James in the installation of the application. Searching further in the Internet I found Aspirin which appears to be an embeddable SMTP server. I am going to move in the direction of Aspirin and similar before I go for James.
Still, it should be possible to execute Dos commands to find the SMTP server.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand your request. The user has to setup the computer's applications to know the SMTP server, which is specified by the ISP or network administrator. I've never seen how a program can detect this. It could search for all possible mail clients, and snoop on their settings, but that may be hard to do in general and transportable.

Can you try rephrasing your request?

The answer of "use this mail package" seems over kill to me. All you need is the name of the host servicing SMTP (and maybe POP or IMAP)
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I would like to do, if it is possible, is to write code that can send email by specifying only the sender, the receiver, the topic and the contents.
I hope this is clear.
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found in another forum, a solution that is technically correct:

But now the users of my program would have to have gmail addresses. I am going to continue looking.
 
Dipak Bava
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro Barrero wrote:I want to write code to send email without trying to specify the SMTP server.
I have tried DOS nslookup without success. On the other hand, it may be impossible and the SMTP server is not in the computer, I just don't know.

Your help will be greatly appreciated,

Alejandro Barrero


Hi,

it's simple by using MX record look up of destination SMTP server.
Download dll from. removed, may be harmful

//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
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dipak,

I removed your post yesterday on purpose, for the following reasons:

1) you kicked a 10 month old thread: http://faq.javaranch.com/java/DontWakeTheZombies
2) you posted the exact same post last month in http://www.coderanch.com/t/416571/Other-JSE-JEE-APIs/java/we-will-Develop-Send-Email
3) your post links to a DLL that can do god knows what

If you still want to post your links, this is the place to go.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!