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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.