I want to send a mail via servlet, I do this as described in the doc
example and the source code given in this mailing list. But it does not
work (no exception). I tried to use sun.net.smtp class earlier and the
mail was sent.
Has anybody got an idea ? (probably the firewall?)
That's the methodcode:
public void mailSenden() throws javax.mail.MessagingException
{
//emailFrom
//emailTo
//msgSubject
//msgBody
String msgContent = new String();
javax.mail.internet.InternetAddress[] empfaenger = new
javax.mail.internet.InternetAddress[1];
// set up properties und session for the message
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", "mail.hv.signal.de");
props.put("mail.from", emailFrom);
javax.mail.Session session =
javax.mail.Session.getDefaultInstance(props,null);
try
{
msgContent = msgBody;
javax.mail.internet.InternetAddress from =
new javax.mail.internet.InternetAddress(emailFrom);
empfaenger[0] = new javax.mail.internet.InternetAddress(emailTo);
javax.mail.Message msg = new javax.mail.internet.MimeMessage(session);
msg.setFrom(from);
msg.setHeader("X-Mailer", "JavaMail");
msg.setSentDate(new java.util.Date());
// f�r folgende anweisung muss import javax.mail.* stehen bleiben:
msg.setRecipients(Message.RecipientType.TO,empfaenger);
msg.setSubject(msgSubject);
msg.setContent(msgContent,"text/plain");
msg.setSentDate(new java.util.Date());
javax.mail.Transport.send(msg);
//session.getTransport(empfaenger[0]).send(msg);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
--
_____________________________________________________________________
Katrin Cappar
SIGNAL Versicherungen Tel: +49 231 135 2409
Abteilung aein-ms Fax: +49 231 135 13 2409
Joseph-Scherer-Str. 3 E-Mail: [EMAIL PROTECTED]
44139 Dortmund
Germany
_____________________________________________________________________
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html