facebook Twitter RSS Feed YouTube StumbleUpon

Home | Forum | Chat | Tours | Articles | Pictures | News | Tools | History | Tourism | Search

 
 


Go Back   BanglaCricket Forum > Miscellaneous > Support

Support Help & Support

Reply
 
Thread Tools Display Modes
  #1  
Old April 1, 2005, 02:49 PM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,675
Default Java Mail Exception

I have written a program that allows users to send articles to other people via email. However, the following error is generated when trying to send the emails:

"Sending failed; nested exception is: javax.mail.MessagingException:
Could not connect to SMTP host: 172.18.2.101, port: 25; nested
exception is: java.net.ConnectException: Connection timed out"



This is what I have so far:

String recipientEmails=request.getParameter(RECIPIENT_EMA ILS);
String senderName=request.getParameter(SENDER_NAME);
String senderEmail=request.getParameter(SENDER_EMAIL);
String senderComment=request.getParameter(SENDER_COMMENT) ;
String articleLink=request.getParameter(ARTICLE_LINK);
String articleTitle=request.getParameter(ARTICLE_TITLE);

try{
Properties props = new Properties();
props.put("mail.smtp.host", application.getInitParameter("mail.smtp.host"));
javax.mail.Session mailSession = javax.mail.Session.getInstance(props, null);
//Session mailSession=Session.getDefaultInstance(new Properties(), null);
MimeMessage message = new MimeMessage(mailSession);

// build recipients
if (recipientEmails!=null){

//just in case the recipient email is in the form abc,xyz
//without a space in between the "," tokenize the emails

StringBuffer recipientEmailBuffer = new StringBuffer();
StringTokenizer st1=new StringTokenizer(recipientEmails,",");
while (st1.hasMoreTokens()){
recipientEmailBuffer.append(st1.nextToken());
recipientEmailBuffer.append(" ");
}

recipientEmails = recipientEmailBuffer.toString();
StringTokenizer st=new StringTokenizer(recipientEmails, EMAIL_SEPARATOR);
while (st.hasMoreTokens()){
Address toAddress=new InternetAddress(st.nextToken());
message.addRecipient(Message.RecipientType.TO, toAddress);
}
}

// build subject
message.setSubject(articleTitle);

// build sender
Address fromAddress=new InternetAddress(senderEmail, senderName);
message.setFrom(fromAddress);

// build text body
StringBuffer sb=new StringBuffer();
sb.append("<#html><#body>");
//sb.append("

Subject: ").append(articleTitle).append("<#br>");
sb.append("This story was sent to you by ").append(senderName);
sb.append(" (").append(senderEmail).append("). Please click on the link below to view the full story.<#br>");
if (senderComment!=null && senderComment.trim().length()>0){
sb.append("<#p>").append(senderComment).append("<#/p><#br>");
}
sb.append("<#hr>").append(articleTitle).append("<#br>");
String httpLink="http://www.*website_name*.com"+request.getParameter(ARTICLE_HTTP_LINK);
sb.append("<#a href='").append(httpLink).append("'>").append(httpLink).append("");
sb.append("");
//message.setText(sb.toString());
message.setContent(sb.toString(), "text/html");

// send email
Transport.send(message);


Any help would be appreciated. Thanks in advance

Edited on, April 1, 2005, 7:52 PM GMT, by AsifTheManRahman.
Reason: sheesh...how do you turn html off on this forum?

Reply With Quote
  #2  
Old April 1, 2005, 03:12 PM
AsifTheManRahman's Avatar
AsifTheManRahman AsifTheManRahman is offline
Super Moderator
BC Editorial Team
 
Join Date: February 12, 2004
Location: Canada
Favorite Player: Ice Man, Chatter Box
Posts: 27,675

i've looked further into it, and looks like the IP "172.18.2.101" can't be detected at all. so it's an IP problem - not a code problem. i'll get it fixed.

thanks for viewing this thread
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On



All times are GMT -5. The time now is 09:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
BanglaCricket.com
 

About Us | Contact Us | Privacy Policy | Partner Sites | Useful Links | Banners |

© BanglaCricket