You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lau Eng Huat <to...@gmail.com> on 2012/01/18 06:04:29 UTC

Sending email ( Tomcat 7 )

Hi guys,

I need to send emails using tomcat servlet. I have the following questions
to ask
1. How to install javaMail ? Is this the best option ?
2. I'm running Tomcat 7 on a local host. Can I sent email to my gmail
account ? How can I achieved this ?

Thanks in advanced

Re: Sending email ( Tomcat 7 )

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lau,

On 1/18/12 12:04 AM, Lau Eng Huat wrote:
> 2. I'm running Tomcat 7 on a local host. Can I sent email to my
> gmail account ? How can I achieved this ?

You want to configure a "smart host" if you want to connect to Gmail
in order to send your messages for you. You might have to configure
your domain's DNS records in order to send lots of messages through
Gmail or you may be blocked as a spammer.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8W41gACgkQ9CaO5/Lv0PAndQCfavspImEKD8iMT0Eadur6pd7X
GgAAnjHOpUCASX+oa20QGycvKl27+q9c
=9jVc
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Sending email ( Tomcat 7 )

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Lau Eng Huat [mailto:tomcathelp@gmail.com] 
> Subject: Sending email ( Tomcat 7 )

> I need to send emails using tomcat servlet.

First, read the docs:

http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html#JavaMail_Sessions

If that isn't sufficient, come back and ask specific questions.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Sending email ( Tomcat 7 )

Posted by "Purvis Robert (NHS CONNECTING FOR HEALTH)" <ro...@nhs.net>.
java.util.Properties p = new Properties();
javax.mail.Session s = javax.mail.Session.getInstance(p);
javax.mail.internet.MimeMessage message = new javax.mail.internet.MimeMessage(s);
try {
   javax.mail.internet.InternetAddress from = new javax.mail.internet.InternetAddress(emailFrom, emailFrom);
   message.setFrom(from);
   message.addRecipient(javax.mail.Message.RecipientType.TO, new javax.mail.internet.InternetAddress(emailTo));
   message.addRecipient(javax.mail.Message.RecipientType.CC, new javax.mail.internet.InternetAddress(emailCc));
   message.addRecipient(javax.mail.Message.RecipientType.BCC, new javax.mail.internet.InternetAddress(emailBccList));
   message.setSubject(emailSubject);
   message.setText(emailBody);
   javax.mail.Transport.send(message);
} catch (Exception e) {
   System.out.println("Email failure: " + e.toString());
}



Robert Purvis


-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: 18 January 2012 07:28
To: Tomcat Users List
Subject: RE: Sending email ( Tomcat 7 )

> From: Lau Eng Huat [mailto:tomcathelp@gmail.com]
> Subject: Sending email ( Tomcat 7 )

> I need to send emails using tomcat servlet.

First, read the docs:

http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html#JavaMail_Sessions

If that isn't sufficient, come back and ask specific questions.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.

Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
For more information and to find out how you can switch, visit www.connectingforhealth.nhs.uk/nhsmail

********************************************************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org