Your javax code looks fine (I have props.put
("mail.transport.protocol", "SMTP" ); also, but I don't recall if it's
necessary). So I'd check to see if the mail server is receiving the
email. A couple ways to do that is to turn on logging on the mail
server (that's not my area of expertise but we've had to do it a time
or two) and/or use a product like Wireshark to look at the traffic on
the network. To do that, you'll need console access to your GWT
server...but sniffing the wire is pretty much the only way to see
what's going on in javax.
Good luck.
On Sep 29, 3:37 pm, Jared Smith <[email protected]> wrote:
> I am having a bit of an issue testing my web application. I have written a
> customized Emailer class that is used to send an email to the specified
> email address. I am able to get the class to successfully send an email
> while using a driver class, however, when I attempt to use the Emailer class
> on the server side, no email is sent. I have embeded the code in a
> try-catch block and I am not catching any exceptions. Does anyone have any
> knowledge as to why this may be the case?
>
> Server Side Code:
> ************************************************************************************************************************
> /**
> * The server side implementation of the RPC service.
> */
> @SuppressWarnings("serial")
> public class EmailServiceImpl extends RemoteServiceServlet implements
> EmailService {
> public String sendEmail(String email) {
> try {
> Emailer eMail = new Emailer();
> eMail.setEmailRecipient(email);
> eMail.setEmailSender(email);
> eMail.setEmailSubject("Its Jail!");
> eMail.setEmailText("No, java mail silly!!...");
> eMail.send();
> return "an email has successfully been sent to the specified
> email address.";
> } catch(Exception e) {
> return "An exception has occured.";
> }
> }}
>
> ************************************************************************************************************************
>
> Emailer class:
> ************************************************************************************************************************
> import java.util.*;
> import javax.mail.*;
> import javax.mail.internet.*;
>
> public class Emailer {
> private String smtpHost;
> private int smtpPort;
> private String emailSender;
> private String emailRecipient;
> private String emailSubject;
> private String emailText;
>
> public Emailer() {
> smtpHost = "*mysmtphost*";
> smtpPort = 25;
> }
>
> public Emailer(String host, int port) {
> smtpHost = host;
> smtpPort = port;
> }
>
> public void setEmailSender(String sender) {
> emailSender = sender;
> }
>
> public void setEmailRecipient(String recipient) {
> emailRecipient = recipient;
> }
>
> public void setEmailSubject(String subject) {
> emailSubject = subject;
> }
>
> public void setEmailText(String text) {
> emailText = text;
> }
>
> public void send() {
> Properties props = new Properties();
> props.put("mail.smtp.host", smtpHost);
> props.put("mail.smtp.port", smtpPort);
> Session ses = Session.getDefaultInstance(props, null);
> Message msg = new MimeMessage(ses);
> try {
> msg.setFrom(new InternetAddress(emailSender));
> msg.setRecipient(Message.RecipientType.TO, new
> InternetAddress(emailRecipient));
> msg.setSubject(emailSubject);
> msg.setText(emailText);
> Transport.send(msg);
> } catch (MessagingException e) {
> e.printStackTrace();
> }
> }}
>
> ************************************************************************************************************************
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---