Sign (smime) javax.mail.Message
hi !
I would like to sign created Message object. I know i have to use SMIMESignedGenerator from BC, but i need to calculate hash in my own way. I can;t figure where it is made in this BC class. I want to return javax.mail.Message object. Please help !
czako
Maybe someone knows how to properly sign javax.mail.Message object ?
Similar Messages
-
Import statement not found for javax.mail.Message
when i'm in webSphere shich is using jdk1.4.2,
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
cannot be found
Where would the Mail classes be located?
Thank youmail.jar and activation.jar, which can be downloaded here:
http://java.sun.com/products/javamail/downloads/index.html
http://java.sun.com/products/javabeans/jaf/downloads/index.html -
SHA1 digest error for javax/mail/Message.class
it's been 4 hrs that i am striving to get around this .....Does any body has any idea why this error appears and how to remedy it ....
help will be much much appreciated....Either:
1. Your mail.jar is corrupted, or
2. You have more than one copy of the javax.mail.Message class in your CLASSPATH. -
Javax.mail.Message getRecipients throwing MessagingException
Hi,
I have written an application that reads emails and extracts information to be stored in a DB. Whilst this application has been in production for 3 years, we have recently noticed that it is having problems retrieving the recipients from some emails. I have not been able to reproduce this problem at all on our test machines so do not have any trace information to hand. Basically, the javax.mail.Message getRecipients is throwing a MessagingException for some emails. Can anyone tell me under what circumstances this might happen and what I might do to retrieve the recipient email addresses from these emails?
Thanks!We're going to need more details to really track this down.
What protocol are you using? If, for example, the exception is due to an IMAP
protocol violation in your server, there may be nothing you can do other than
getting a fix for your server from your server vendor.
If you're using POP3, all the message parsing happens in JavaMail, and illegal
addresses can cause exceptions. In this case you can set the System property
"mail.mime.address.strict" to "false". That will prevent the exception in most
or all cases, but won't necessarily give you an address you can do anything with.
You'll need a recent version of JavaMail for this to work well. -
Javax.mail.message.recipienttype not found
Hi,
I use jdev10g and i want to send a mail message.
Here's a little snip of my class for sending a mail.
Jdeveloper gives me a error about Message.RecipientType.TO.
"Member 'RecipientType' not found in javax.mail.Message"
import javax.mail.Message;
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
I've installed the javamail-1.1.3 API.
In my project properties -> libraries, i've added this library with the correct path to the jar file.
I'm sure that this API have this Message class.
What is going wrong, have i missed something ???
Greetings,
PeterHi! Srikanth,
1. I checked MailerEJB.deploy under "Dependency Analyzer",
I checked activation.jar and mail.jar under the J2EE node.
I did the same for the MailerJSP.deploy.
2. I used same jdeveloper version and jdk 1.3.1_06.
3. I did a clean deploy for the ejb and mailerjsp.deploy
4. I recompiled and run the jpr,
from the message window, I got:
C:\jdeveloper\jdk\bin\javaw.exe -ojvm -classpath C:\oc4j\samples\ejb\EJBCallsJSP\classes;C:\oc4j\samples\ejb\EJBCallsJSP;C:\jdeveloper\jdev\lib\jdev-rt.jar;C:\jdeveloper\j2ee\home\lib\activation.jar;C:\jdeveloper\j2ee\home\lib\ejb.jar;C:\jdeveloper\j2ee\home\lib\jaas.jar;C:\jdeveloper\j2ee\home\lib\jaxp.jar;C:\jdeveloper\j2ee\home\lib\jcert.jar;C:\jdeveloper\j2ee\home\lib\jdbc.jar;C:\jdeveloper\j2ee\home\lib\jms.jar;C:\jdeveloper\j2ee\home\lib\jndi.jar;C:\jdeveloper\j2ee\home\lib\jnet.jar;C:\jdeveloper\j2ee\home\lib\jsse.jar;C:\jdeveloper\j2ee\home\lib\jta.jar;C:\jdeveloper\j2ee\home\lib\mail.jar;C:\jdeveloper\j2ee\home\oc4j.jar;C:\jdeveloper\jdbc\lib\classes12.jar;C:\jdeveloper\jdbc\lib\nls_charset12.jar oracle.otnsamples.ejbcallsjsp.mailclient.MailClientSample
I didn't see any error from this message window.
5. The no provider for smtp error is prompted from the mail client.
From above settings and running the application, I couldn't figure out where the error was coming from ?
Thanks
David -
Error using javax.mail package
Hi,
I have included the package javax.mail.* in my code.I have downloaded
jaf 1.0.2 and javamail 1.1.3 from the Sun Microsystems website.
When i try to compile my code i get the error message:
com/voxspectrum/ccvox/EmailServer.java:55: cannot resolve symbol
symbol : class MimeMessage
location: class com.voxspectrum.ccvox.EmailServer
javax.mail.Message msg = new MimeMessage(session);
I am using JDK ver 1.3.1_02. What should i set my path and classpath as, if i am using javax.mail package?
Please could you help me out with this problem!Hi Nisha
You need to include the path to the mail.jar and activation.jar files in your classpath.
How you do it depends on the OS you are running on
in Windows 95 /98 the easiest way is to edit the autoexec.bat file and add the settings to your already existing classpath statement i.e.
set CLASSPATH=%CLASSPATH%;C:\richard\javamail-1.3\mail.jar C:\richard\jaf-1.0.2\activation.jar
(excuse the word wrapping) then reboot
on Linux / Solaris edit the .profile file for your user and set the CLASSPATH variable to
CLASSPATH=$CLASSPATH:<pathtofile>/mail.jar:<pathtofile>/activation.jar
export CLASSPATH
and that should do it
Hope this helps -
Including StringBuffer object in my mail message
I am getting text from the textarea of my jsp page
<textarea name="reason" rows="5" cols="40"></textarea>
StringBuffer comment = new StringBuffer(request.getParameter("reason"));
int loc = (new String(comment)).indexOf('\n');
while(loc > 0){
comment.replace(loc, loc+1, "<BR>");
loc = (new String(comment)).indexOf('\n');
I have save this in a StringBuffer object, comment. Now I want the comment to be the text of my mail message
msg.setText( comment );
When I compile this, I get the message
"SRSBean.java": Error #: 300 : method setText(java.lang.StringBuffer) not found in class javax.mail.Message at line 659, column 9
How can I include the text in the comment object in my mail ?Yes that works. But when i check my email i see that the <BR> is inserted.
i want this to be a new line in the mail. how can i do this? -
Javax.mail.*; not being seen by portal in EP 6
Hello All,
It seems that when I deploy the following code:
package com.giggity;
import java.util.Properties;
import javax.mail.*;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class Mailer extends AbstractPortalComponent
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
Properties p = System.getProperties();
p.put("mail.host", "stmail");
try{
MimeMessage message =
new MimeMessage(Session.getInstance(p, null));
message.setFrom(new InternetAddress("[email protected]")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]"));
message.setSubject("No work");
message.setText("Does not work");
Transport.send(message);
catch(Exception e)
I get a javax/mail/Address ClassNotFoundException. In
the IDE (Eclipse with PDK plugin, not using NW04), it
compiles and builds just fine. What is the problem?
Thanks.
-GregSuccessful compilation or building in the eclipse/NWDS does not mean that it can be successfully deployed on the portal. If the Java build path has all the required jars, any project compiles and builts fine but that build path is not transported to the portal( see inside any par file, there won't be any .classpath and .project files. They are local only files).
========
Add all your third party jar files to the component in this path( ..\dist\PORTAL-INF\lib). There is no need to add mail.jar as it's already available in sap j2ee engine. So add these lines to the portalapp.xml. (as told by jagdeep)
<application-config>
<property name="PrivateSharingReference" value="SAPJ2EE::library:mail"/>
</application-config>
Regs,
Bobby -
Import javax.mail not found problem
I have downloaded the most recent mail.jar and activation.jar files and have created a library w/in JDev called javamail and have added these jars to that library. I have also included this library in my ViewController Project. The problem I am having is that the following imports statements are not found by JDev:
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
When I open up the mail.jar I can find all of these classes, so why are these imports not being recongnized?
I have also tried import javax.mail.*; to include everthing and this does not work either.
Does anyone have any suggestions on how to trouble shoot this issue?Try to add the J2EE library - which is predefined in JDeveloper- to your project's libraries.
Worked for me. -
Javax.mail jar compilation error
Dear friends,
I have created a DC which manages emails to users which uses the following import statements
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
i downloaded the javax.mail package which was supposed to contain the needed jars and added it to the DC ( preferences->add ext libraries->)
But i still find errors in the code.......
Did i import the right package or should the jars be added in another way??
Thanks and regards
SantoshKumarThanks for your response Levy, can u please help me in which folder under /eclipse/plugins does that jar file exist and by what name?
We are using JDK 1.4.2_16 and NWDS 7.0.0 and the portal server is on 1.4.2_12 and EP7.0 SP15 does this cause problem because we are facing a classversion error on deployment. What version of JDK is preferable to our environment??
Thanks and regards
SantoshKumar A -
Javax.mail.SendFailedException: 553 sorry, that domain isn't in my list of
i have put all the lines in the code required to set the server name and the username and the password but it still gives me the error. i have the following code to send the mail.
package com.wesra.mail;
import java.io.PrintStream;
import java.util.Hashtable;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class SendEmail extends Authenticator
InternetAddress from = null;
InternetAddress to = null;
InternetAddress cc = null;
InternetAddress bcc = null;
String subject = null;
Object body = null;
Message msg = null;
static Session session = null;
String msgText = null;
Properties prop = null;
MimeMultipart mimemultipart = null;
public SendEmail()
from = null;
to = null;
cc = null;
bcc = null;
subject = null;
body = null;
msg = null;
msgText = null;
prop = null;
mimemultipart = null;
msgText = new String("");
prop = System.getProperties();
mimemultipart = new MimeMultipart();
public void setDetails(String s, String s1, String s2, String s3, String s4, String s5)
throws Exception
from = new InternetAddress(s1);
to = new InternetAddress(s);
cc = new InternetAddress(s2);
bcc = new InternetAddress(s3);
subject = new String(s4);
body = new MimeBodyPart();
prop.put("mail.smtp.host", s5);
public boolean sendEmail(String s, int i)
throws Exception
session = Session.getDefaultInstance(prop, null);
MimeMessage mimemessage = new MimeMessage(session);
MimeMultipart mimemultipart1 = new MimeMultipart();
if(i > 1)
mimemessage.setRecipient(javax.mail.Message.RecipientType.CC, cc);
if(i > 2)
mimemessage.setRecipient(javax.mail.Message.RecipientType.BCC, bcc);
mimemessage.setRecipient(javax.mail.Message.RecipientType.TO, to);
mimemessage.setSubject(subject);
msgText = s;
MimeBodyPart mimebodypart = new MimeBodyPart();
mimebodypart.setContent(msgText, "text/html");
mimemultipart1.addBodyPart(mimebodypart);
mimemessage.setContent(mimemultipart1);
mimemessage.setFrom(from);
System.out.println("Message is being sent...");
Transport.send(mimemessage);
System.out.println("Message Sent Successfully");
return true;
i write the following lines to call the code.
se1.setDetails(to,from,to1,to2,subject,server);// this is called with the appropriate parameters with the server being either wesra.com,wesra.in or nmims.edu but none of that works.please check it and let me know what is wrong.
boolean sentstatus=se1.sendEmail(msgText1,number);It sounds like a configuration problem with your SMTP server. Perhaps the machine from which you're connecting to the mail server isn't allowed to send mail to other domains. That'll be something you need to fix on the mail server.
Anyway, I'd suggest plugging that error message into Google... you'll get hundreds of matches. -
I need to save the body of email message in db. But I couldn't found method of Message class.
Could you please advice me how it can be done?sesembeki wrote:
I need to save the body of email message in db. But I couldn't found method of Message class.javax.mail.Message?
Could you please advice me how it can be done?getContent()
~ -
E-Mail Receiver QPAC: javax.mail.FolderClosedException
Hi,
Recently the EmailReceiver QPAC refuses to get E-Mails. I configured it using IMAP. But lately, it sporadically refuses to get new messages and throws a
javax.mail.FolderClosedException as posted below.
ERROR [com.adobe.workflow.AWS] stalling action-instance: 3873 with message: javax.mail.FolderClosedException: * BYE Connection down
at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:751)
at javax.mail.Message.setFlag(Message.java:541)
at com.adobe.workflow.qpac.emailreceiver.MessageWrapper.setDeletedFlag(MessageWrapper.java:313)
at com.adobe.workflow.qpac.emailreceiver.EmailReceiverService.processEmail(EmailReceiverService.java:301)
at com.adobe.workflow.qpac.emailreceiver.EmailReceiverService.runTask(EmailReceiverService.java:103)
at com.adobe.workflow.tools.qde.pat.service.PATAbstractPollingServiceEx.execute(PATAbstractPollingServiceEx.java:87)
at com.adobe.workflow.engine.PEUtil.executeAction(PEUtil.java:184)
The JavaDoc is pretty weird:
This exception is thrown when a method is invoked on a Messaging object and the Folder that owns that object has died due to some reason.
What does it mean
a folder has died? Is there a bug with the EmailReceiver, which
kills folders, after getting messages? :-)
StevePretty weird.
It looks like the connection to the mailbox might have closed while you were busy processing the message.
Are you:
- downloading very large message
- do you have a large number of messages in that folder
- are you connecting through a proxy server or something that might be terminating the connection
- are you using an unreliable network connection?
Any of the above might cause this problem.
Good luck...
howard
http://www.avoka.com -
Error: javax.mail.SendFailedException
Hi all,
I have a requirement to send a mail on click of a button. I have written a simple java code using java mail API. But while running the application i am getting
javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
If i run the java code as a standalone java application everything is fine. Only in webdynpro application i am getting the above mentioned error.
My question is do we have to configure any settings in the WAS. If so, can somebody give me a detailed answer how to do the configuration.
Thanks and Regards,
RathnaI stopped the Antivirus service and checked the application but it doesn't help.
Here is the code. But the code is working fine.
// Get system properties
Properties props = new Properties();
// Setup mail server
props.put("mail.pop3.host","myserver");
props.put("mail.pop3.auth","true");
Authentication auth = new Authentication("[email protected]","abcd");
Session session = Session.getInstance(props,auth);
Store store = session.getStore("pop3");
store.connect("myserver","[email protected]","abcd");
System.out.println("Connected");
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress("[email protected]"));
message.setSubject("Hello JavaMail Attachment");
// create the message part
MimeBodyPart messageBodyPart = new MimeBodyPart();
//fill message
messageBodyPart.setText("Hi");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
String fileAttachment="D:\Message.txt";
DataSource source = new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileAttachment);
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
javax.mail.Transport.send(message);
System.out.println("Mail sent successfully");
store.close(); -
Javax.mail.SendFailedException: 550 5.7.1 Unable to relay
Hi All,
I am getting the below Exception message when I am executing my JavaMail
program.
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
Please can anyone help me out.
Regards,
Ravi.what's wrong to this source code, if try to send mail to local account actually it success, but if i try to send mail eg:[email protected](outside my network) i found error this error to. i had to try not use encode userID/password into base64, but the result doesn't change.
if anyone have solution for this problem, please contact me @ [email protected]
Regards,
agam
error returned by java:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 Relaying is prohibited
void com.sun.mail.smtp.SMTPTransport.sendMessage(javax.mail.Message, javax.mail.Address[])
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import com.sun.mail.smtp.SMTPTransport;
import com.agam198.util.*;
public class PCMMail{
String sMailServer = "";
String sUserID = "";
String sPassword = "";
int iPort = 25;
String sTo = "";
String sFrom = "";
String sCC = "";
Message msg = null;
SMTPTransport transport = null;
Transport trns = null;
public PCMMail(StringPool sPool){
this.sMailServer = sPool.getString("SMTPServer.SERVER");
this.sTo = sPool.getString("SMTPAlert.TO");
this.sFrom = sPool.getString("SMTPAlert.FROM");
this.sCC = sPool.getString("SMTPAlert.CC");
this.sUserID = sPool.getString("SMTPServer.LOGIN");
this.sPassword = sPool.getString("SMTPServer.PASSWORD");
this.iPort = Integer.parseInt(sPool.getString("SMTPServer.PORT"));
initConnection();
public void initConnection(){
try{
System.out.println("MailServer: "+sMailServer);
System.out.println("To: "+sTo);
System.out.println("From: "+sFrom);
System.out.println("CC: "+sCC);
Properties props = new Properties();
props.put("mail.smtp.host", "152.118.89.0");
Session session = Session.getDefaultInstance(props,null);
trns = session.getTransport("smtp");
if(trns == null){
System.out.println("trans is not null");
else
System.out.println("trans null");
trns.connect(sMailServer,Base64.base64Encode ( sUserID ),Base64.base64Encode ( sPassword ));
if(trns.isConnected()){
System.out.println("connected to SMTP SERVER");
else{
System.out.println("not connect");
InternetAddress address = new InternetAddress();
//create a message
msg = new MimeMessage(session);
catch(Exception e){
public void sendMessage(String message){
sendMessage(getFirstLine(message),message);
public void sendMessage(String subject,String message){
try{
//prepare message
msg.setFrom(new InternetAddress(sFrom));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(sTo));
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(message);
trns.send(msg);
System.out.println("message sent");
catch(Exception e){
e.printStackTrace();
public String getFirstLine(String message){
BufferedReader buf = new BufferedReader(new StringReader(message));
try{
return buf.readLine();
catch(Exception e){
return " ";
public static void main(String[] args){
StringPool sp = new StringPool();
sp.set("SMTPServer.SERVER","152.118.89.0");
sp.set("SMTPServer.PORT","25");
sp.set("SMTPServer.LOGIN","kiara");
sp.set("SMTPServer.PASSWORD","kiara");
sp.set("SMTPAlert.TO","[email protected]");
sp.set("SMTPAlert.FROM","[email protected]");
sp.set("SMTPAlert.CC","");
PCMMail pcm = new PCMMail(sp);
pcm.sendMessage("subject","message body");
}
Maybe you are looking for
-
Background Colour in Pages 5.0.1
Knowing how Apple likes to have everything sent electronically, and not printed, I am surprised that I can't change the background page colour of documents. I can change the background of a word, sentence and paragraph. I can even select all the text
-
Iv topped up with a gift card but the account is still asking for a credit card, any Idea's? Thanks
-
hi, i�m trying to develop with the JCOP tools but i would like to have more information about APIs (java) and the diferences between packages included in the CD (JCOP 30,10,21id,21sim...).I�ve used the documentation in the CD,JCOP xx technical briefs
-
Problem with ES PRO Password - attention - system install ES Battery
I bought program EC PRO Password on BlackBerry. It install program EC Battery. This programme, I don't care !!!. 1,99$ is little pen-case, but I dislike it!!!
-
I have an email with an attachment that requires a password the open. I can open the file but embedded in the attachment is another attachment. When I double click attachment I get the following error message. Acrobat cannot open the file attachme