Actually I do have one further problem. Is there any way that the program can catch emails that bounce back because the to address is invalid? At the moment they just come into my inbox but I want it so that they cause an error in my code e.g Mail delivery failed: returning message to sender. If the address is invalid e.g [EMAIL PROTECTED] I want an Java exception to catch this rather than just get a bounced email.

Is there any way to do this?

Mark

----- Original Message ----- From: "Mark Whitby" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, March 11, 2006 3:43 PM
Subject: Re: Problems with JavaMail


Len,

Thanks very much for your help, my class is now working fine. Ironically enough my smtp server is localhost as I use an ssh client to connect to my Universities mailhost via the ssh connection and then my emails go via that.

Mark

----- Original Message ----- From: "Len Popp" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, March 11, 2006 3:32 PM
Subject: Re: Problems with JavaMail


You need to look at the SMTP server settings in Outlook Express and
use the same settings in your JavaMail config. The mail.smtp.host for
example shouldn't be "localhost", it should be whatever email server
Outlook Express uses (look in Tools > Accounts).
--
Len

On 3/11/06, Mark Whitby <[EMAIL PROTECTED]> wrote:
Thanks for the email Len,

So if that's the case where am I going wrong with my code to get the error
described in my first email?  What settings do I need to change in my
current configuration to get my code to work?

Many thanks

Mark

----- Original Message -----
From: "Len Popp" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, March 11, 2006 3:15 PM
Subject: Re: Problems with JavaMail


Yes, you need an SMTP server. If you've got Outlook Express running,
you can use the same server it's using.
--
Len

On 3/11/06, Mark Whitby <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I'm currently getting the following error when trying to test the > JavaMail
> set up: javax.mail.MessagingException: Could not connect to SMTP host:
> localhost, port: 25; nested exception is: java.net.ConnectException:
> Connection refused: connect
>
> I'm using Tomcat 5.5 and have installed the jar files correctly as > stated
> here: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
>
> I'm guessing that there's a problem with my SMTP settings.  However,
> (apologise if I sound dense here) but the only mail client I have on my > PC
> is Outlook Express.  Am I right in saying then that as well as JavaMail
> that I need an smtp server? If so where can I get one? If not where > am I
> going wrong?
>
> I have the following setups in my files:
>
> context.xml:
>
> <Context>
>
>  <ResourceLink name="jdbc/TestDB"
>   type="javax.sql.DataSource"
>      global="jdbc/TestDB"/>
>
> <ResourceLink name="mail/Session" auth="Container"
>             type="javax.mail.Session"
>             mail.smtp.host="localhost"/>
>
> </Context>
>
> web.xml:
>
> <resource-ref>
>   <description>JavaMail Connection</description>
>   <res-ref-name>mail/Session</res-ref-name>
>   <res-type>javax.mail.Session</res-type>
>   <res-auth>Container</res-auth>
> </resource-ref>
>
> Finally this is the code i'm testing:
>
> Context initCtx = new InitialContext();
>             Context envCtx = (Context) initCtx.lookup("java:comp/env");
>             Session session = (Session) envCtx.lookup("mail/Session");
>
>             Message message = new MimeMessage(session);
> message.setFrom(new > InternetAddress("[EMAIL PROTECTED]"));
>             InternetAddress to[] = new InternetAddress[1];
>             to[0] = new InternetAddress("[EMAIL PROTECTED]");
>             message.setRecipients(Message.RecipientType.TO, to);
>             message.setSubject("Test email");
>             message.setContent("Test email", "text/plain");
>             Transport.send(message);
>
> Can anyone tell me where I'm going wrong?
>
> Many thanks
>
> Mark Whitby
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to