Again, im not quite sure what im trying to send emails from, i can probably use my email, which is a gmail account. I tried that and i also tried adding my account and password to the properties but it still does nothing
On Mon, Feb 28, 2011 at 3:04 PM, Greg Dougherty <[email protected]>wrote: > > When i GWT Compile i get no errors at all. > > GWT Compile is client side. What you're doing is done, and can only > be done, on the server. Where are you trying to send the mail from? > > Greg > > On Feb 28, 4: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. > > -- 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.
