If your server impl is getting called, it's not really a GWT question, but I notice you're trying to use smtp.gmail.com as your SMTP host. I highly doubt that's allowed due to spam potential.
/dmc On Mon, Feb 28, 2011 at 5:28 PM, GrahamH <[email protected]> wrote: > Hi all, > > Im trying to set up my GWT app so that it can send emails. > > I have the code to send the email in a server-side servlet class. I > have downloaded the Java Mail API and the JAF and included both the > mail.jar and the activation.jar files to the external jars. > > Here is my Code: > > import java.util.Properties; > > import javax.mail.Message; > import javax.mail.MessagingException; > import javax.mail.Session; > import javax.mail.Transport; > import javax.mail.Message.RecipientType; > import javax.mail.internet.AddressException; > import javax.mail.internet.InternetAddress; > import javax.mail.internet.MimeMessage; > import javax.activation.*; > > import com.google.gwt.user.server.rpc.RemoteServiceServlet; > > import cs.ubc.ca.cs310.HockeyPool.client.EmailService; > > public class EmailServiceImpl extends RemoteServiceServlet implements > EmailService { > /** > * > */ > private static final long serialVersionUID = 1L; > > public void sendEmail(String email){ > Properties props = System.getProperties(); > props.put("mail.smtp.host", "smtp.gmail.com"); > props.put("mail.smtp.port", "465"); > > Session mailSession = Session.getDefaultInstance(props); > Message simpleMessage = new MimeMessage(mailSession); > > InternetAddress fromAddress = null; > InternetAddress toAddress = null; > try { > fromAddress = new InternetAddress(" > [email protected]"); > toAddress = new InternetAddress(email); > } catch (AddressException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > try { > simpleMessage.setFrom(fromAddress); > simpleMessage.setRecipient(RecipientType.TO, > toAddress); > simpleMessage.setSubject("HockeyPool PoolAdmin > Invitation"); > simpleMessage.setText("Hello,<br /><br />You have > been added as a > Pool Administrator for our Hockey Pool System"); > > Transport.send(simpleMessage); > System.out.println("email sent"); > } catch (MessagingException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > > When i GWT Compile i get no errors at all. > Even when i debug the program it executes all of this code just fine > and never hits an exception but the email is NEVER sent. > > Another thing is every single post about using Java Mail tells me i > need the activation.jar but the following line gives me a warning that > the activiation is never used anywhere in my class > > import javax.activation.*; > > Any help is much appreciated > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- David Chandler Developer Programs Engineer, Google Web Toolkit w: http://code.google.com/ b: http://googlewebtoolkit.blogspot.com/ t: @googledevtools -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
