Tuesday, September 28, 2010

Sending mails from GWT-App

Hi,

I'm trying to send an email from my GWT-App. I found the following
code using google:
protected void sendMessage(String smtpHost, String fromAddress, String
fromName, String to, String subject, String text) {
// Get system properties Properties
props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", smtpHost);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(fromAddress, fromName));
// Set the to address
message.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));
// Set the subject
message.setSubject(subject);
// Set the content
message.setContent(text, "text/html");
// Send message
Transport.send(message);
}

But I'm getting a "java.lang.AssertionError: null".

I was wondering why I do not have to enter a password for the smtp-
server, and what to enter at String smtpHost, as I have to enter my
Smtp-Host at props.put() again ...

Thanks!
Tom

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment