Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-13-2010, 07:37 AM
Starter Member
 
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 01-13-2010, 07:50 AM
Zimbra Consultant & Moderator
 
Posts: 20,316
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
Reply With Quote
  #3 (permalink)  
Old 01-13-2010, 08:50 AM
Starter Member
 
Posts: 2
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.
Reply With Quote
  #4 (permalink)  
Old 01-13-2010, 08:51 AM
Moderator
 
Posts: 7,928
Default

Perhaps check your log files to ascertain why it is not working
__________________
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.