cancel
Showing results for 
Search instead for 
Did you mean: 

Send email, using SMTP on remote host

Former Member
0 Kudos

Hi! I've a WebDynPro file that tries to send email using smtp. I've a code in a Servlet that works fine in a Tomcat in the same server machine. But the same code in the WebDynPro in SAP doesn't work. I need some special configuration? some kind of permissions or activate some option? As I said, the same code works on a servlet in tomcat in the same machine, but the same code doesn't work in SAP, so I don't have a clue.



response.write("Some test text");
try {

	Properties props = new Properties();
	props.put("mail.transport.protocol", "smtp");
	props.put("mail.smtp.host", SMTP_HOST_NAME);
	props.put("mail.smtp.auth", "true");
	props.put("mail.smtp.port", "26");

	Authenticator auth = new SMTPAuthenticator();
	Session session = Session.getDefaultInstance(props, auth);

	session.setDebug(true);

	
	MimeMessage message = new MimeMessage(session);
	message.setSubject("Testing javamail plain");
	message.setContent("This is a test", "text/plain");
	message.setFrom(new InternetAddress("from@something"));
	message.setRecipient(
		Message.RecipientType.TO,
		new InternetAddress("to@something"));
		
	Transport transport = session.getTransport();
	//Transport.send(message);
	transport.connect();
	transport.sendMessage(
		message,
		message.getRecipients(Message.RecipientType.TO));
	transport.close();
} catch (MessagingException exc) {
	exc.printStackTrace(out);
} catch (RuntimeException exc){
	exc.printStackTrace(out);
}

As you can see, I put a response before the try. When I enter the page, the text of the response is displayer, but after that an exception is thrown:

For some very strange problem, the forum doesn't let me to post the exception. If I do it, all the formatting is lost, so I will just post the first error, since I think is the most important:

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

I put the activation and mail jar files (provided by SUN) in SAP and in the Tomcat. The only thing that I can think, is that SAP is loading other activation, or it is not compatible with the activation provided by SUN.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Just use sockets, work well and fast.

Former Member
0 Kudos

Hi,

Can u pls tell how have u worked with socket programming?

Thanks.

Former Member
0 Kudos

I removed all those external jars, but the results where exactly the same. Nevertheless I manage to send my msg. I did it with

Socket

, writing directly to the sock. May be is reinventing the wheel, but it worked, and worked well and pretty fast.

Thanks to all for your time.

Regards!

Former Member
0 Kudos

Where can I find the standard output console in SAP? I'm using session.debug(true) to see the trace of the connections attempts, but can't find where the output is.

Temporarily I'm already sending the email using Sockets, but still want to know how to do it with JavaMail.

Regards!

former_member185706
Participant
0 Kudos

hi,

please remove any mail.jar, activation.jar from your application classpath - SAP Java server has its own.

Best regards

Bojidar

Former Member
0 Kudos

Hi,

you can go upto 1.4.2_17, or 19.

go through these and validate,

http://fisheye5.cenqua.com/browse/glassfish/mail/src/java/com/sun/mail/smtp/SMTPTransport.java?r=1.1...This will give your chnages/upations of JDK versions.

/thread/5387124 [original link is broken]

if you not able to get the solution, please open OSS message because SAP keep on update the issues from these errors especially for Tomcat servers.

All the best

nag

Former Member
0 Kudos

Hi! I'm looking at those notes. 128865 is for financial, so its not related, but 616712 is. I'm validating and evaluating the steps that are provided. It says to check my SP, so I did this and post the info for you:

Software Components all components...

Name Version Applied

sap.com/SAP-JEECOR 7.00 SP17 (1000.7.00.17.0.20080917225335) 20090127190023

sap.com/SAP-JEE 7.00 SP17 (1000.7.00.17.0.20080917225228) 20090127185946

VM system properties...

PID: 6368

Name: Java HotSpot(TM) 64-Bit Server VM

Vendor: Sun Microsystems Inc.

Version: 1.4.2_16-b05

VM Parameters

The documents tells to upgrade to SP12, in this case I've 17, so it's a lot newer (and by experiencie, not always de new is better than the old)

I'll keep looking at the notes and google, maybe someone has an idea while I do this? Thanks!

Former Member
0 Kudos

Hi,

As an initial level,please make sure you have latest JAVA installed in your system.

validate these notes.

128865,616712

regards

nag

Former Member
0 Kudos

In this post I post the full exception:


java.lang.NoSuchMethodError: com.sun.activation.registries.MailcapFile.getMailcapList(Ljava/lang/String;)Ljava/util/Map; 
at javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:558) 
at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:625) 
at javax.activation.DataHandler.writeTo(DataHandler.java:329) 
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:264) 
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1299) 
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2071) 
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2039) 
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1739) 
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:737) 
at com.steren.distribuidor.devoluciones.servlet.PruebasVarias.doContent(PruebasVarias.java:57) 
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209) 
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114) 
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328) 
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136) 
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189) 
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215) 
at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645) 
...

Doing:


transport.sendMessage(
		message,
		message.getRecipients(Message.RecipientType.TO));