cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mail: NoSuchProviderException: No provider for SMTP

06-25-2007 1:26 PM
5262 views 6 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi experts,

please can someone help my by the following error:

<b>NoSuchProviderException: No provider for SMTP</b>


public class SendJavaMail {
	
	private static String status;
	private static String status_transport;

	public static String generateMail() {
		
		Properties props = new Properties();
		props.setProperty("mail.smtp.host", "ServerName");
		props.setProperty("mail.smtp.auth" , "false");
		
		Session session = Session.getDefaultInstance(props);
		
		try {
		MimeMessage mMeassage = new MimeMessage(session);
		mMeassage.setSubject("Subject");
		mMeassage.setText("Hello");
		InternetAddress fromAddress =
		new InternetAddress("[email protected]");
		InternetAddress toAddress =
		new InternetAddress("[email protected]");

		mMeassage.setFrom(fromAddress);
		mMeassage.setRecipient(Message.RecipientType.TO,  
                                toAddress);
		Transport transport = session.getTransport("SMTP");
		status_transport = String.valueOf(transport);
		<b>transport.connect("ServerName", "", "");</b>
		transport.send(mMeassage);
		transport.close();
		status = "Mail verschickt";
			
		} catch (MessagingException e) {
		status = e.getMessage();
		try{
		<b>Transport transport = session.getTransport("SMTP");</b>
		status_transport = String.valueOf(transport);
		}
		catch(NoSuchProviderException pe){
		status_transport 
                                = "NoSuchProviderException: "+pe.getMessage();	
		}
			
		}
		status = "Status Transport: "+status_transport+" 
                                Status: "+status;
		return status;
	}
}

I think transport.connect("ServerName", "", "") is not correct and

Transport transport = session.getTransport("SMTP") I get the error:

NoSuchProviderException

Have anyone an idea? Thanks in advanve!

If i change:

<b>transport = session.getTransport("smtp");</b>

I get the error:


java.lang.NoSuchMethodError: com.sun.activation.registries.MailcapFile.getMailcapList(Ljava/lang/String;)Ljava/util/Map;

Message was edited by:

SAP User

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

DeeptiChavare
Active Participant
0 Likes

Hi,

Did you find the solution of your problem?

I am facing same problem while sending mail. I have imported three jar files:

1) mail.jar

2) activation.jar

3) smtp.jar

Still getting exception : <b>'javax.mail.NoSuchProviderException: No provider for SMTP '</b>

How did you solve your problem?

Thanks,

Deepti

Former Member
0 Likes

I solved the problem by an other way. I used a WebService which already exists in my company to send mails.

If you find an other solution please let me know.

SAP User

Former Member
0 Likes

you need to include References for mail.jar in portalapp.xml

Answers (3)

Answers (3)

Former Member
0 Likes

Hi,

include mail.jar,activation.jar,smtp.jar and other mail jar files in your classpath .

See that only one version of this jar's added to the classpath.

Answer if usefull...... reward with points.

Thanks

Ritu

Former Member
0 Likes

Hi SAP user,

have you added smtp.jar file to your project?? If you want to send mail to User's then you must have 3 jar files with you they are:

1) mail.jar

2) activation.jar

3) smtp.jar(present in java mail package)

For more info on sending mails, refer to this code:

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/send%2bmail%2bcode

Regards

Kunal Saggar

P.S. Award points if it helps you.

Former Member
0 Likes

Hi,

Go to the below link