JAVA – Send email From JAVA Application & Command Line – Febootimail
Sending an email from a JAVA application.
I’ve discovered another great tool this week – Febootimail.
It allows you to send an email from the command line – meaning that you can send an email from any JAVA application running on a windows OS. Not just basic emails, but HTML email, attachments etc.
STEP 1 Download & Install febootimail.exe:
The Febootimail application can be downloaded from the following location -
http://www.febooti.com/downloads/
and look for the setup / installer EXE.
Once downloaded run the setup process – the default setup location is C:\Program Files\febooti Command line email\
When the install is complete navigate to the install directory and look for a file called febootimail.exe.
This is the EXE that you will call from your JAVA application. If you only intend running your application on your local pc then this is fine. I run it from a server side application, so copied febootimail.exe to a server location accessible from all the clients running my JAVA app.
STEP 2 Call Febootimail.exe From the Application:
The following is an extract from a simple class that will send an email.
try{
String cmd;
cmd = “ C:\Program Files\febooti Command line email\febootimail.exe”; // LINE1
cmd += ” -SERVER mail.yourserver.net”;//LINE 2
cmd += ” -FROM info@yourdomain.co.uk”; // LINE 3
cmd += ” -TO toaddress@whoever.com” ; // LINE 4
cmd += ” -MSG This is the body of the email address”; // LINE 5
cmd += ” -HTML “; // LINE 6
cmd += ” -SUBJ This Is The Subject”; // LINE 7
cmd += ” -FROMNAME fromaddress@yourdomain.com”; // LINE 8
cmd += ” -AUTH AUTO -USER username -PASS password “; // LINE 9
Process p = Runtime.getRuntime().exec(cmd);
}
catch(Exception e){
e.printStackTrace();
}
Line 1: Points JAVA to febootimain.exe. Change the location depending on where you placed the exe.
Line 2: Supply your mail server name.
Line 3: Supply a FROM address.
Line 4: the recipient email address.
Line 5: This is the message body. This could be HTML code.
Line 6: Tells febootimail.exe to expect HTML in the message body.
Line 7: Sets the subject.
Line 8: sets the from name – this will abear as the sender alias.
Line 9: The username and password for your mail server.
Loading...
thank u
krishna - October 19, 2009 at 7:24 am
sir can you tell how to attach files to the email and send
krishna - October 19, 2009 at 7:45 am
i am getting this error. please explain me about this.
SMTP error: an unexpected response after login
couldn’t connect to server, Error: (no additional information available)
krishna - October 19, 2009 at 11:47 am