Wrox Programmer Forums
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 16th, 2006, 07:40 AM
Friend of Wrox
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default Cannot send mail

 whats the error in this code? I am not able to send mail. Getting error

"Cannot connect to SMTP host thru port 25"

If I send thru ASPMail, its working(SMTP)

This is my code...

// Sending e-mail
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
public final class EMailer
public static void main( String[] aArguments )
 Properties p=System.getProperties();
 p.put("mail.from","rakesh_muraharisetti@yahoo.com. sg");
 EMailer emailer = new EMailer();
 //the domains of these email addresses should be valid,
 //or the example will fail:
 emailer.sendEmail("rakesh_muraharisetti@yahoo.com. sg", "rakesh_muraharisetti@yahoo.com.sg","Success", "Successfully sent from PVPSIT");
public void sendEmail( String aFromEmailAddr, String aToEmailAddr, String aSubject, String aBody )
 Properties p=System.getProperties();
 Session session = Session.getInstance(p, null);
 MimeMessage message = new MimeMessage( session );
  //the "from" address may be set in code, or set in the
  //config file under "mail.from" ; here, the latter style is used
  //message.setFrom( new InternetAddress(aFromEmailAddr) );
  message.addRecipient(Message.RecipientType.TO, new InternetAddress(aToEmailAddr));
  message.setSubject( aSubject );
  message.setText( aBody );

Old March 16th, 2006, 09:09 AM
Authorized User
Join Date: Mar 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

Quick check: Is port 25 open?

If you're running this within a company environment; their IT groups like to block ports for the fun of it... oh, sorry, I mean, for "security" reasons.

Old March 16th, 2006, 09:54 PM
Friend of Wrox
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post


  Thanx for the reply. How to check whether the port 25 is open or not?

Old March 17th, 2006, 01:39 AM
Friend of Wrox
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post


  I checked using

telnet mydomain.com 25

its not connecting.

How can i open this port?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
send mail chavakoti BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 September 4th, 2007 05:03 AM
How to send mail Jolley_tolson PHP How-To 0 August 13th, 2007 03:38 AM
how to send a mail ashokparchuri General .NET 2 March 24th, 2005 07:55 AM
The mail can't be send jabby General .NET 2 September 8th, 2004 05:14 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.