How do i logon to exchange server using javamail API.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kishore_Koya
Posted On:   Monday, November 25, 2002 09:12 AM

With the Following code i was able to send mail to myself with in the company, but not to hotmail account. How do i logon to Exchange mail server from JavaMail to send mails to hotmail or yahoo etc. <%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %> <% Properties props = new Properties(); props.put("mail.smtp.host", "exchange.xyz.com"); Session s = Session.getInstance(props,null); MimeMessage message = new MimeMessage(s); InternetAddress from = new InternetAddres("abcd@xyz.com"); message.setFrom(from); InternetAddress to = new InternetAddress("abcd@xyz.com"); message.addRecipient   More>>

With the Following code i was able to send mail to myself with in the company, but not to hotmail account.
How do i logon to Exchange mail server from JavaMail to send mails to hotmail or yahoo etc.

			
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "exchange.xyz.com");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);

InternetAddress from = new InternetAddres("abcd@xyz.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("abcd@xyz.com");

message.addRecipient(Message.RecipientType.TO, to);

message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");

Transport.send(message);
%>

TIA,
Kishore.    <<Less

Re: How do i logon to exchange server using javamail API.

Posted By:   moon_departed  
Posted On:   Monday, November 25, 2002 11:11 PM

You need to turn on the authenticate by adding line

props.put("mail.smtp.auth", "true");
, and instead of using

Transport.send(message);
, try

Transport transport = session.getTransport("smtp");
transport.connect("exchange.xyz.com", username, password);
message.saveChanges();
transport.sendMessage(message, message.getAllRecipients());
transport.close();


Hopefully this will help.

Re: How do i logon to exchange server using javamail API.

Posted By:   Michael_Bosch  
Posted On:   Monday, November 25, 2002 10:12 AM



Are you sure the e-mail server supports relaying to outside hosts? If you're able to send internally then your code is working and I don't see anything wrong with what you have above.



My guess is that this is more of an internal network configuration at your company. It's possible the exchange server requires some sort of authentication to route e-mail externally.

About | Sitemap | Contact