sending mail thru a jsp

Occasional Contributor

sending mail thru a jsp

I am trying to send mail using sendmail on linux redhat 9.0 on a jsp page. i am executing from Runtime calss' exec(string),
where the string is
String string[]={"/bin/sh","-c","sendmail","thte commend worked fine on command line but not working thru' jsp, any problem in my approach.
Steven E. Protter
Exalted Contributor

Re: sending mail thru a jsp

check dns setup


If you get an answer sendmail should send.

See if your message is being queued but not delievered
sendmail -q -v
see the error.

Respond to the error.
Make sure sendmail is not got a DS directive in

You do not want to try relaying mail off your isp' smtp server unless they allow that.

You might need to check with your isp. Some are thinking about blocking outbound port 25 traffic to keep their customers from sending spam.

Steven E Protter
Owner of ISN Corporation
Stuart Browne
Honored Contributor

Re: sending mail thru a jsp

What error are you getting when that is exec'd?

Three possible errors I can see are these:

Path in an exec environment probably doesn't have either '/usr/sbin' or '/usr/lib' thus 'sendmail' on it's own (not path'd) won't work.

The '< messagefile' requires that 'messagefile' be in the current-working-directory. Unless you can gaurantee that the CWD has 'messagefile', use the full path to it.

Given the manner in which you're populating the String, I'd assume that each individual argument is supposed to be on it's own. You're stacking 'sendmail' and '' on top of each other. Try separating these as well.

So in summary, try this:

String string[]={"/bin/sh", "-c", "/usr/lib/sendmail", "", "< /full/path/to/messagefile"};
One long-haired git at your service...
Joao Mendes
Occasional Advisor

Re: sending mail thru a jsp

Try the jsp attached, it uses javamail class, it works fine in my host.
It is better than your approach using sendmail.
just substitute with yours smtp host.

Joao Mendes