05-10-2011 10:51 AM
<property name="mailServerHost" value="my.smtp.com" />
<property name="mailServerPort" value="25" />
<property name="mailServerDefaultFrom" value="my@email.com" />
<property name="mailServerUsername" value="my@email.com" />
<property name="mailServerPassword" value="mypass" />Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", SMTP_HOST_NAME);
props.setProperty("mail.smtp.auth", "true");
//props.setProperty("mail.smtp.localhost", "localhost");
Session mailSession = Session.getDefaultInstance(props, new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
}
});
mailSession.setDebug(true);
Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
message.setContent("This is a test", "text/plain");
message.setFrom(new InternetAddress(SMTP_AUTH_USER));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(TO_ADDRESS));
transport.connect();
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
transport.close();05-11-2011 08:14 AM
05-12-2011 06:01 AM
05-12-2011 07:49 AM
mail.smtp.localhost: Local host name used in the SMTP HELO or EHLO command. Defaults to InetAddress.getLocalHost().getHostName(). Should not normally need to be set if your JDK and your name service are configured properly.Source: http://javamail.kenai.com/nonav/javadocs/com/sun/mail/smtp/package-summary.html
DEBUG: setDebug: JavaMail version 1.4.4
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "XXX.com.br", port 25, isSSL false
220 XXX.com.br Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Thu, 12 May 2011 08:45:15 -0300
DEBUG SMTP: connected to host "XXX.com.br", port: 25
EHLO André-PC
501 5.5.4 Invalid Address
HELO André-PC
501 5.5.4 Invalid Address
Exception in thread "main" javax.mail.MessagingException: 501 5.5.4 Invalid Address
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2023)
at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:1440)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:644)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at br.com.test.MailTest.main(MailTest.java:40)Thank you for your time,
05-13-2011 04:52 AM
05-13-2011 07:33 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.