About Java Mail Api ...Please help..?
Hi,
I am sending email thruogh java mail api. Email has sent but in console, It is in debug mode as this is the messages:
DEBUG: JavaMail version 1.4.1*
DEBUG: not loading file: C:\Program Files\Java\jdk1.6.0_10\jre\lib\javamail.providers*
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.6.0_10\jre\lib\javamail.providers (The system cannot find the file specified)*
DEBUG: !anyLoaded*
DEBUG: not loading resource: /META-INF/javamail.providers*
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers*
DEBUG: Tables of loaded providers*
+DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}+*
+DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}+*
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map*
DEBUG: !anyLoaded*
DEBUG: not loading resource: /META-INF/javamail.address.map*
DEBUG: not loading file: C:\Program Files\Java\jdk1.6.0_10\jre\lib\javamail.address.map*
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.6.0_10\jre\lib\javamail.address.map (The system cannot find the file specified)*
it is printing more statements. I just want to remove that can i ? I had tried session.setDebug(false). But still showing me debug messages. please tell me it is really urgent.
thanks in advance.
Manveer
Edited by: Manveer-Singh on Feb 2, 2010 5:25 PM
Remove the logger statement from your program,
or
Check your IDE is in debug mode
or
paste your code and tell what environment are you using.
Similar Messages
-
Java Mail Program - Please Help!
Hi everyone, I am new to Java (been learnig for about 6 months) and I was hoping you could help me.
I would like to write a program to be able to send and receive email (a basic version of outlook express), the prblem is that i have no idea on how to start such a program as i have only written programs such as calculators before.
I was hoping someone could tell me how to begin such a challenging program, which java package is best to create such a program, Jbuilder or the normal javac compiler.
Thanks everyone for your helpSee the Java mail API for more details (javax.mail if I remember well). This can be found at:
http://java.sun.com/products/javamail/index.html
Hope it helps,
Stephane -
How to attach a word file in JAVA mail? Please help
I am a JAVA rookie and I have problem attaching a word file using javamail. I searched almost all the forum but still couldn't find the solution.
Sorry for the reposting. But can anybody please help me out? Your any words or links will be highly appreciated!
LakobeIf you want to include an attachment with your message, you need to build up the parts, quite literally, because the name of the applicable interface is Part. The content of your Message will consist of multiple parts within a Multipart object. Part one of the message is a BodyPart that contains the message content. Part two of the message is a BodyPart that contains the attachment. The attachment itself is specified as a DataSource. You don't have to actually read the attachment.
You start in the same way as you do for a message without an attachment. Create the message from the session and initialize the headers:
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("JDC Attachment");
However here you need to create the Multipart object:
Multipart multipart = new MimeMultipart();
For part one, create a BodyPart and set the text to be a message. Then, add the BodyPart to the Multipart you just created.
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Here's the file");
multipart.addBodyPart(messageBodyPart);
For part two, you need to create a BodyPart again, but this time you need to create a DataSource for the file.
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
Use a DataHandler object to attach the data source to the message. Simply create a DataHandler for the source and attach it to the message:
messageBodyPart.setDataHandler(
new DataHandler(source));
Remember to set the filename of the attachment. This permits the recipient to know the name (and type) of the received file.
messageBodyPart.setFileName(filename);
Attach part two in the same way as part one:
multipart.addBodyPart(messageBodyPart);
And as a final step before sending, attach the Multipart to the Message:
message.setContent(multipart); -
Failed to build Java Mail API 1.4.5 with maven-3.0.4
Hi,
I am trying to build Java Mail 1.4.5 with Maven-3.0.4 using default settings of maven.
It is getting failed to build due to following errors -
[ERROR] COMPILATION ERROR :
[INFO] -----------------------------------------------------------
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[210,37] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[369,47] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[913,29] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[916,29] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[919,29] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[922,29] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[925,29] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[928,29] cannot find symbol
symbol : variable Version
location: class javax.mail.Session
[INFO] 8 errors
[INFO] -----------------------------------------------------------
[INFO] ----------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------------------------------
[INFO] Total time: 1:51.197s
[INFO] Finished at: Tue Jan 08 13:06:01 IST 2013
[INFO] Final Memory: 12M/67M
[INFO] ----------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:compile (default-compile) on project javax.mail: Compilation failure: Compil
ation failure:
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[210,37] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR]\Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[369,47] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[913,29] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[916,29] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[919,29] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[922,29] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR]\Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[925,29] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR] \Workarea\mySourceData\src\Mail\mail\src\main\java\javax\mail\Session.java:[928,29] cannot find symbol
[ERROR] symbol : variable Version
[ERROR] location: class javax.mail.Session
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on
project javax.mail: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation fail
ure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExceptionSame issue I am facing when I am trying to build Java Mail with netbeans - 7.2.1, it getting failed with same version issue in Session.java class.
How can I set this Version in Session.java class to get rid of this error?
If we can use nexus repository then please let me know how to set this.
Thanks,
Neelam SharmaI answered this question here:
http://stackoverflow.com/questions/14217596/failed-to-build-java-mail-api-1-4-5-with-maven-3-0-4/14288418#14288418 -
Error while sending mail when using Java Mail API
Hi Experts,
I am trying to execute a webdynpro application which uses the Java Mail API to send emails. The exception that I get on executing the application is :
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]
Can anybody please help me sort out the issue.
Regards
AbdullahHi,
Usually one get this error if the SMTP server is configured not to relay mails (a security measure) or the SMTP server need the mail to be sent from a trusted IP or with proper authentication. Some SMTP servers are configured to block junk mails.
Pls check with your mail server administrator.
Regards -
Save Attachment from exchange server 2010 from oracle using java mail API
Hello,
I want to read email from microsoft exchangeserver 2010 and save attachement into a folder.I created an Java program to import attachments from a exchange server mailbox using "POP3S".It works fine when run as a java application.But when i put this inside Oracle11g R2 using load java and while executing from a procedure it gives an error at parsing message into Multipart
Error at line : Multipart mp = (Multipart)m.getContent();
Error:
Content-Type: multipart/mixed;
boundary="_002_A0C2E09A..................................."
java.lang.ClassCastException
at mailPop3.checkmail(mailPop3:71)
My Java Class is as follows,
import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Date;
The function i used to check for attachments is given below.
public static boolean hasAttachments(Message m) throws java.io.IOException, MessagingException
Boolean hasAttachments = false;
try
// if it is a plain/html text - no attachements
if (m.isMimeType("text/*"))
return hasAttachments;
else if (m.isMimeType("multipart/alternative"))
return hasAttachments;
else if (m.isMimeType("multipart/*"))
Multipart mp = (Multipart)m.getContent();
if (mp.getCount() > 1)
hasAttachments = true;
return hasAttachments;
catch (Exception e) {
e.printStackTrace();
} finally {
return hasAttachments;
My Java Details as follows
java Version :1.5.0_10
java.vm.specification.version:1.0
java.vm.version :1.5.0_01
java.specification.version:1.5
java.class.version:48.0
Java mail API:javamail-1.4.4
Used Jars:mail.jar
Could someone explain why I am getting this error? What can I do to resolve this error?
Is any other Jar need other than mail.jar?
Any help would be much appreciated.
Regards,
NisanthHai EJP,
Thanks for your reply,
My full java class as follows,
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Part;
import javax.mail.Multipart;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeMessage;
public class Newmail
public Newmail()
super();
public static int mailPOP3(String phost,
String pusername,
String ppassword)
Folder inbox =null;
Store store =null;
int result = 1;
try
String host=phost;
final String username=pusername;
final String password=ppassword;
System.out.println("Authenticator");
Authenticator auth=new Authenticator()
protected PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(username, password);
System.out.println("Certificate");
String filename="D:\\Certi\\jssecacerts";
String password2 = "changeit";
System.setProperty("javax.net.ssl.trustStore",filename);
System.setProperty("javax.net.ssl.trustStorePassword",password2);
Properties props = System.getProperties();
System.out.println("host-----"+props);
props.setProperty("mail.pop3s.port", "993");
props.setProperty("mail.pop3s.starttls.enable","true");
props.setProperty("mail.pop3s.ssl.trust", "*");
Session session = Session.getInstance(props,auth);
session.setDebug(true);
store = session.getStore("pop3s");
System.out.println("store------"+store);
store.connect(host,username,password);
System.out.println("Connected...");
inbox = store.getDefaultFolder().getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
Message[] msgs = inbox.getMessages();
System.out.println("msgs.length-----"+msgs.length);
result = 0;
int no_of_messages = msgs.length;
for ( int i=0; i < no_of_messages; i++)
System.out.println("msgs.count-----"+i);
System.out.println("Attachment....>"+msgs.getContentType());
Multipart mp = (Multipart)msgs[i].getContent();
System.out.println("Casting Success" + mp.getContentType());
catch(Exception e)
e.printStackTrace();
finally
try
if(inbox!=null)
inbox.close(false);
if(store!=null)
store.close();
return result;
catch(Exception e)
e.printStackTrace();
return result;
Please check it
Regards,
Nisanth -
Oracle Java Mail API exception in Jdev 11.1.15
we are using java mail api to send out emails. and wrap it in java embedding with in our webservice.
we are using jdeveloper 11.1.1.5 for this and the Java API is failing with the below error, we have included all the java libraries. As code is working fine in Jdeveloper 11.1.2
we tried different version of jdeveloper ( 11.1.1.5, 11.1.1.7 ) but its still the same. Can some one please suggest
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at bts.mail.SendMailTLS.main(SendMailTLS.java:50)
Caused by: javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420)
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)
at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384)
at javax.mail.Service.connect(Service.java:297)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at bts.mail.SendMailTLS.main(SendMailTLS.java:45)Can Some body help me with this please
-
Using Java mail API from JSPDynPage
Hi Experts,
I am working on a Portal Assignment that requiresto sent work flow mails on the basis of error conditions.
Can u please suggest if at all I can use Java Mail APIs from JSP page within the JSP DYN Page Framework.
If at all Java Mail can be used could u please suugest some help docs on the same.
Thanks for the help.
Manab C Ghosh
EP Consultant
Kolkata INDIA
+919830603327Hi Experts,
Thanks for all the responses to my Mail question(mailing from JSPDynPage).
I have found the solution.
Here is how I have got the things: (pls note there are other solns)
Using Java Mail APIs;
Create a Java file in the scr.core / src.api
MailSender.java
* Created on Jul 21, 2005
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
package com.mailsend.test;
import java.util.Date;
import java.util.Properties;
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;
* Edited on Jul 24, 2005
* @author Manab C Ghosh
public class MailSender {
public String sendMessage(){
String msg ="Hello mail Test";
String smtpServer ="mySMTPServer";
String smtpSender = "senderemailaddress";
String smtpRecipient="receipientemailaddress";
String stBody = msg ;
//String stDate = new Date().toString() ;
String stSubject = "Mail Test ";
Send( smtpServer, //SMTPServer
smtpSender, //Sender
smtpRecipient, //Recipient
stSubject, //Subject
stBody //Body
); //Attachments
return "Mail Success";
public static void Send(String SMTPServer,
String From,
String To,
String Subject,
String msgText1
// Error status;
int ErrorStatus = 0;
// create some properties and get the default Session
Properties props = System.getProperties();
props.put("mail.smtp.host", SMTPServer);
Session session = Session.getDefaultInstance(props, null);
try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(From));
InternetAddress[] address = {new InternetAddress(To)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(Subject);
// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msgText1);
// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
//mp.addBodyPart(mbp2);
// add the Multipart to the message
msg.setContent(mp);
// set the Date: header
msg.setSentDate(new Date());
// send the message
Transport.send(msg);
} catch (MessagingException mex) {
Call this file from the JSP page (which is set at JSPDynPage controller)
one important thing-----
Create a dir under PORTAL-INF and import the following jars-- activation.jar, mail.jar,imap.jar,smtp.jar, mailapi.jar.
This works..
Thanks once again to the Experts.
happy mailing
Manab Ghosh.
INDIA (+919830603327) -
How to use Java Mail API in Unix
I am trying to write some code using Java mail API. I want to execute it in Unix. I downloaded the mail API to windows machine and ftped the mail.jar file to a Unix machine. Then I set the class path as below:
export CLASSPATH=$CLASSPATH:/home.../mail.jar
Then I tried to compile my Java program. The output is as below:
error: error reading /home.../mail.jar; invalid END header (bad central directory offset)
mail.java:1: package javax.mail does not exist
import javax.mail.*;
Can any one please help me out.You should also include the "activation.jar" file that you obtained from
downloading the Java Activation Framework, in your CLASSPATH.
For example:
export CLASSPATH=$CLASSPATH:/urPath/activation/activation.jar
Besides, assuming you unzipped javamail-1_4_1.zip in home/download the following should work
export CLASSPATH=$CLASSPATH:home/download/javamail-1.4.1/mail.jar:. -
Problem with sending mail throgh java mail api
hi folks,
We are having problem regarding sending mail using java mail api.
we are using msgsendsample.java file from demo folder contained in javamail-1.3.3_01 folder.
we are using following command at dos prompt.:
java msgsendsample [email protected] [email protected] smtp.mail.yahoo.com false
It gives following Exception:
--Exception handling in msgsendsample.java
com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for hel
p go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
333) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:906)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:535)
at javax.mail.Transport.send0(Transport.java:151)
at javax.mail.Transport.send(Transport.java:80)
at msgsendsample.main(msgsendsample.java:93)
** ValidUnsent Addresses
[email protected]
Thanking in Advance...
Please give us guidance to any alternate solution if exists.hi
the smtp server u are using should allow u to send mail to other smtp server like if u r sending mail to yahoo account u have to use yahoo smtp server only .....
bye -
Java mail api - sending mails to gmail account
Hello
I am using java mail api to send mails.when i send mails to gmail from ids which are not in gmail friends list, most of the mails are going to spam.Ofcourse, some of them go to inbox.I tried in lot of ways to analyse the problem.But nothing could help. Can anyone plzz tell me how to avoid mails going to spam in gmail, using java mail api?
Thank you in advance,
Regards,
Aradhana
Message was edited by:
Aradhanaam using the below code.
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port","25");
props.put("mail.smtp.auth", isAuth);
Authenticator auth = new UserAuthenticator();
// Get session
Session s = Session.getDefaultInstance(props,auth);
// Define message
Message m = new MimeMessage(s);
// setting message attributes
try {
m.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
InternetAddress f_addr=new InternetAddress(from);
f_addr.setPersonal(personalName);
m.setFrom(f_addr);
m.setSubject(subject);
m.setSentDate(new Date());
m.setContent(msg,"text/plain");
m.saveChanges();
// send message
Transport.send(m);
Message was edited by:
Aradhana -
How can i access gmail's smtp server using java mail api
i m using java mail api to access gmails pop and smtp service to receive and send mail from ur gmail account. I m able to access gmails pop server using the ssl and port 995 , but i can not use its smtp server to which i m connecting using ssl on 465 port. It requires authentication code.
if anybody can help me in this regard i m thnkful to him/her.
thnks in advance.
jogin desaiHere's an example of using SSL + Authentication
http://onesearch.sun.com/search/onesearch/index.jsp?qt=ssl+authentication&subCat=siteforumid%3Ajava43&site=dev&dftab=siteforumid%3Ajava43&chooseCat=javaall&col=developer-forums -
Hi
We have a requirement to create a custom e mail. For the same I am trying to use Java Mail API.I am facing an issue with the following code:
session session1 = session.getInstance(properties, null);
System gives an error Sourced file: inline evaluation of: ``Properties props = new Properties(); session session1 = session.getInstance(prop . . . '' : Typed variable declaration : Class: session not found in namespace
Is there some specific API i need to import for session class. Kindly suggest.
Regards
ShobhaHi Shobha,
I was also facing the same issue from last couple of weeks and just now i have achieved the working functionality.
Please find below working code and replace values as per your serveru2019s configuration.
import com.sap.odp.api.util.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.File;
import java.net.*;
// SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
String to =<email address>;
String from =<email address>;
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = <smtp host name>;
String user = <smtp user name>;
// Create properties, get Session
// Properties props = new Properties();
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", host);
props.put("mail.debug", "false");
props.put("mail.smtp.auth", "false");
props.put("mail.user",user);
props.put("mail.from",from);
Session d_session = Session.getInstance(props,null);//Authenticator object need to be set
Message msg = new MimeMessage(d_session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test E-Mail through Java");
msg.setSentDate(new Date());
msg.setText("This is a test of sending a " +
"plain text e-mail through Java.\n" +
"Here is line 2.");
Transport.send(msg);
Deepak!!! -
Java.lang.UnsupportedClassVersionError while using java mail api
Hi Everybody ,
I am new comer to this forum , and would like to be an active member.
I am getting this error while trying to use the java mail api to send an email using smtp.
The error is as follows :
Exception in thread "main" java.lang.UnsupportedClassVersionError: javax/mail/Message (Unsupported major.minor version 48.0)
Can Anyone please tell where I am wrong.
I am using the following code
==============================================================
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.abc.com");
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Optional : You can also set your custom headers in the Email if you Want
msg.addHeader("MyHeaderName", "myHeaderValue");
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
==============================================================Hi Philip ,
Thanks for the prompt reply , I had installed oracle client services which overid my jdk1.4 installation with jdk1.3 and hence the error. I changed my classpath settings to point to jdk1.4 and it owrked properly.
Thanks once again.
regards,
Rupesh Rajan -
String "iso-8859-1" found in subject line of java mail API(when German char
We have written a mail client using java mail API and it works fine. Some body sends the email with subject line contains German chars(using some other mail client like outlook)
and our mail client is running on the machine whose Local has been set 'German'.
Now, while getting the subject line
Javax.mail.Message email; //local variable
// some how I am intializing email.
String str = email.getSubject();
the value of str returns "Bitte die 4 Items I�schen. Kein Bedarf. Ich kann die=?iso-8859-1?Q?_L=F6schung_nic?="
but actual value subject line was "Bitte die 4 Items I�schen. Kein Bedarf. Ich kann die L�schung nic"
So '�' char was repalced by some arbit chars.
Moreover, Charset.defaultCharset().name() returns 'windows-1252'
Please suggest me how I can get the actual subject line
Thanks
-Sanjeevhttp://forum.java.sun.com/thread.jspa?threadID=741111&messageID=4250621
visit it
by ghanshyam
Maybe you are looking for
-
What is the report to get a List vendors - total invoiced amounts during a certain period Thanks SK
-
Hello, We have a HTTP --> RFC synchronous scenario. We have 8 fields in request but we want to log only 6 of them in XI. The other 2 fields should not be logged anywhere in XI. Is that possible? Thanks, Beena.
-
Software for backup of external disk
I have the latest MacBook Pro Retina 15 with 16gb of RAM but am having problems with one of my external HDDs (1TB LaCie Rugged USB 3.0/2.0). I was using 500GB for Time Machine and that seemed to be working well but when trying to write to the other
-
Does ReportDocument leak memory?
<p class="ssiBODYCOPY">Using CrystalDecisions.CrystalReports.Engine.ReportDocument XI R2.<br /><br />w3wp.exe memory use raises while a report is generated (which is expected), yet it does not seem to be ever released after. If you keep generating sa
-
hi, i have a very nice tree with leafs and nodes, now i want to show a dialog with information every time the user double clicks in a tree leaf... anyone thanks in advance