• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't send mail with gwt

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yo!

I have a problem with sending mail when using GWT. I have tested the code I've written without using GWT which works fine, but when it is in a GWT project it doesn't send any mails at all.

I run the the method on the server side in GreetingServiceImpl. And can see that the mail runs when I press a button, but nothing seems to be sent. No network traffic goes out when trying to call the sendMail method either.
I'm using eclipse. What can be wrong?

code for method sendMail(String subject, String message, String from, String[] recipients, byte[] attachment)

boolean debug = false;

//Set the host smtp address
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.port", "25");
props.setProperty("mail.host", "x.x.x.x");
props.setProperty("mail.from", from);
props.setProperty("mail.smtp.auth", "false");

// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
try {
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
catch (NullPointerException e) { e.printStackTrace(); }
catch (AddressException e) { e.printStackTrace(); }
catch (MessagingException e) { e.printStackTrace(); }

Be nice!
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Are you using GAE along with GWT? If yes, GAE, in development mode, does not send out actual emails, but just prints it to the log
http://code.google.com/appengine/docs/java/mail/overview.html#Development_Server
 
Kristian Delin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:Welcome to the Ranch.

Are you using GAE along with GWT? If yes, GAE, in development mode, does not send out actual emails, but just prints it to the log
http://code.google.com/appengine/docs/java/mail/overview.html#Development_Server



Yep! unmark appengine did the trick. You have been very kind! Thank you!
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome!
 
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic