struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patil, Sheetal" <pati...@diebold.com>
Subject RE: urgent- exception in sending e-mail from application
Date Fri, 16 Jun 2006 05:38:36 GMT
Hi again

I have made some change in code like

                Transport tran=session.getTransport ();
                tran.send (message);

now this change is giving me exception like 

javax.mail.NoSuchProviderException: Invalid protocol: null

so please help me to resolve this 

Shital 

-----Original Message-----
From: Mon Cab [mailto:futon33@yahoo.com] 
Sent: Friday, June 16, 2006 10:48 AM
To: Struts Users Mailing List
Subject: Re: urgent- exception in sending e-mail from application

Patil 

Your smtp server may require authentication.  Find out and, if so, Add
the following lines to your code.  


class MyAuthenticator extends Authenticator
{
	protected PasswordAuthentication getPasswordAuthentication()
	{
	     PasswordAuthentication pa =
new
PasswordAuthentication(username,password);
		return pa;
	}
}

props.put("mail.smtp.auth", "true");
Authenticator a1= new MyAuthenticator();
Session mailsession = Session.getDefaultInstance(props, a1);



--- "Patil, Sheetal" <patils1@diebold.com> wrote:

> 
> Hello friends
> I am trying to send mail from my application
> Here is the code
>             Properties properties = System.getProperties ();
>             properties.put ("mail.smtp.host","smtp host name");
>             
>             Session session = Session.getDefaultInstance
> (properties,null);
>             
>             Message message = new MimeMessage (session);
>             try
>             {
>                 message.setFrom (new InternetAddress
> ("patils1@diebold.com"));
>                 message.setRecipient (Message.RecipientType.TO,new
> InternetAddress ("patils1@diebold.com"));
>                 message.setSubject ("Hi ");
>                 message.setText ("How is it going ?");
>                 message.setSentDate (new Date ());
>                 Transport.send (message);
>                 System.out.println ("Message sent !!!");
>             }
>             catch (MessagingException e)
>             {
>                 e.printStackTrace ();
>             }
> 
> But this code is giving me exception 
> javax.mail.MessagingException: Could not connect to SMTP host:
> smtp-host-name, port: 25
> is there any additional setting's required for this one
> plse let me know 
> Sp
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message