You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Luong Phan <lu...@yahoo.com> on 2003/09/09 14:25:53 UTC

How to use sendmail program (in Jakarta-Tomcat)

Hi all,
 
I am designing a website. I use JSP and Java as programming language, Jakarta-tomcat as server, and Mysql to store database. I have just downloaded a sendmail program written by Per, but I do not know how to use it. Please help me!
 
Thank you very much!
 
LuongPhan 


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Re: How to use sendmail program (in Jakarta-Tomcat)

Posted by Pranas <ba...@danet.lt>.
Your cat try using http://jakarta.apache.org/commons/net/index.html
----- Original Message ----- 
From: "Luong Phan" <lu...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, September 09, 2003 2:25 PM
Subject: How to use sendmail program (in Jakarta-Tomcat)


> Hi all,
>
> I am designing a website. I use JSP and Java as programming language,
Jakarta-tomcat as server, and Mysql to store database. I have just
downloaded a sendmail program written by Per, but I do not know how to use
it. Please help me!
>
> Thank you very much!
>
> LuongPhan
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software


Re: How to use sendmail program (in Jakarta-Tomcat)

Posted by Christopher Williams <cc...@ntlworld.com>.
Does the sendmail program use SMTP (presumably it does, because it wouldn't
be very useful otherwise)?  If so, use the JavaMail API:

import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;

String mailhost = ...;
String from = ...;
String to = ...;
String subject = ...;
String msgText = ...;

Properties props = new Properties();
props.put("mail.host", mailhost);
javax.mail.Session mailConnection =
    javax.mail.Session.getInstance(props, null);
Message msg = new MimeMessage(mailConnection);

msg.setContent(msgText, "text/plain");
msg.setFrom(new InternetAddress(from));
msg.setRecipient(new InternetAddress(to));
msg.setSubject(MimeUtility.encodeText(subject));

Transport.send(msg);


Two files, mail.jar and activation.jar, need to be pathed in for this code
to work.  If this isn't suitable for you, I've written some code which you
can use to talk to the SMTP server directly and will let you have if you get
in touch directly.