Results 1 to 4 of 4

Thread: Smtp Zimbra Server and Java

  1. #1
    leandro.bravo is offline Starter Member
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    5

    Default Smtp Zimbra Server and Java

    Hello to all,
    I have written a Java application in order to connect me to my server mail smtp Zimbra and to send mails. For the connection i use tls with the port 25. I have tested the code with the mail of Gmail and works ok.
    The Code is this:
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;

    public class JspMail
    {
    String d_email = "piporo@pipoflauto.com",
    d_password = "haihaihai",
    d_host = "mail.mysmtpserver.com",
    d_port = "25",
    m_to = "steve.jobs@apple.com",
    m_subject = "Testing",
    m_text = "Hey, this is the testing email.";

    public JspMail()
    {
    Properties props = new Properties();
    props.put("mail.smtp.user", d_email);
    props.put("mail.smtp.host", d_host);
    props.put("mail.smtp.port", d_port);
    props.put("mail.smtp.starttls.enable","true");
    props.put("mail.smtp.auth", "true");
    //props.put("mail.smtp.debug", "true");
    props.put("mail.smtp.socketFactory.port", d_port);
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");

    SecurityManager security = System.getSecurityManager();

    try
    {
    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getInstance(props, auth);
    //session.setDebug(true);

    MimeMessage msg = new MimeMessage(session);
    msg.setText(m_text);
    msg.setSubject(m_subject);
    msg.setFrom(new InternetAddress(d_email));
    msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
    Transport.send(msg);
    }
    catch (Exception mex)
    {
    mex.printStackTrace();
    }
    }

    public static void main(String[] args)
    {
    JspMail blah = new JspMail();
    }

    private class SMTPAuthenticator extends javax.mail.Authenticator
    {
    public PasswordAuthentication getPasswordAuthentication()
    {
    return new PasswordAuthentication(d_email, d_password);
    }
    }
    }

    Help Please, Thanks

  2. #2
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,201
    Rep Power
    56

    Default

    For submitting mail through an MTA you should be using port 587 (the RFC Submission port) and not port 25. Port 587 in Zimbra 6.x is already set to use TLS authentication, try that port and check the configuration setting in the Zimbra postfix configuration file.

    BTW, you don't actually say if you've set your Zimbra server to accept TLS authentication.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    leandro.bravo is offline Starter Member
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    5

    Default

    phoenix thanks for the respond. Of Course my server Zimbra accept tls authentication. I have another client, and this works very good with the port 25 and tls.
    I change the port number like you say, but the application have the same problem.

  4. #4
    uxbod's Avatar
    uxbod is offline Moderator
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,016
    Rep Power
    24

    Default

    Perhaps check your log files to ascertain why it is not working

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 02-25-2009, 04:39 AM
  2. Upgrade to ZCS 5.10
    By blozancic in forum Installation
    Replies: 0
    Last Post: 10-21-2008, 08:03 AM
  3. My Zimbra Server crashed this morning...
    By glitch23 in forum Administrators
    Replies: 3
    Last Post: 04-07-2008, 01:28 PM
  4. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM
  5. 3.1 on FC4 problems
    By cohnhead in forum Installation
    Replies: 8
    Last Post: 05-26-2006, 11:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •