cancel
Showing results for 
Search instead for 
Did you mean: 

sending mail thru a jsp

vasudha_2
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 rec@hisadd.com","thte commend worked fine on command line but not working thru' jsp, any problem in my approach.
3 REPLIES
Steven E. Protter
Exalted Contributor

Re: sending mail thru a jsp

check dns setup

nslookup hisadd.com

If you get an answer sendmail should send.


mailq
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 sendmail.cf

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.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
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 'rec@hisadd.com' on top of each other. Try separating these as well.

So in summary, try this:

String string[]={"/bin/sh", "-c", "/usr/lib/sendmail", "rec@hisadd.com", "< /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 smtp.telepac.pt with yours smtp host.

Joao Mendes
Portugal