The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problems with SMTP settings

Discussion in 'E-mail Discussions' started by Mo, Nov 11, 2003.

  1. Mo

    Mo Active Member

    Joined:
    Nov 21, 2001
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I want to send email via my servlets in Tomcat and trying to configure the server.xml with my email settings, in the value field for mail.smtp.host I have mail.domain.com where domain is my current domain. But I still am not able to sent mail - any ideas?
     
  2. netendea

    netendea Member

    Joined:
    Jan 18, 2002
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Hey Mo,

    Try something like this -- works for us...

    Authenticator aAuth = new SMTPAuthenticator();

    Properties aProp = System.getProperties();
    aProp.setProperty("mail.smtp.host", SMTP_HOST_NAME);
    aProp.setProperty("mail.smtp.auth", "true");
    Session session = Session.getInstance(aProp, aAuth);
    ....
    ....


    private class SMTPAuthenticator extends javax.mail.Authenticator
    {
    protected PasswordAuthentication getPasswordAuthentication()
    {
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    return new PasswordAuthentication(username, password);
    }
    }


    Good Luck
    David
     
  3. Mo

    Mo Active Member

    Joined:
    Nov 21, 2001
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    Hi David,

    Thanks for the code, so where SMTP_HOST_NAME is this should be mail.domain.com for example?

    Thanks again :)
     
  4. netendea

    netendea Member

    Joined:
    Jan 18, 2002
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Yes -- these are static values in our java classes -- Note also the auth userid and password toward the bottom of the code snippet. You must authenticate to the SMTP server with a valid userid and password.

    Regards,
    David
     
Loading...

Share This Page