aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes cant send mail using JavaMail API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "cant send mail using JavaMail API" Watch "cant send mail using JavaMail API" New topic
Author

cant send mail using JavaMail API

Jyothsna Panchagnula
Ranch Hand

Joined: Jul 11, 2005
Posts: 113
Hi all,

I am using the following code the send email and I see lot of errors..




can any one tell me where am i going wrong?



thanks,
Jyothsna
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
Seems to be the same issue several times - you haven't added authentication to your code. The JEE FAQ links to an extensive JavaMail tutorial that has code examples for how to do this.


Ping & DNS - my free Android networking tools app
Vivek Mathur
Greenhorn

Joined: Jun 29, 2007
Posts: 25
Hi Jyothsna !

I once tried to do it, with the Authentication.

You need to set the properties as below and use Authenthicator class object that would do the authentication and pass it to the sessions constructor.




Check it out, it may help.

rahman sharif
Greenhorn

Joined: Jul 17, 2013
Posts: 1
full project help me how to clear error i think due to jar files


D:\>javac trail.java
trail.java:8: package javax.mail.internet does not exist
import javax.mail.internet.MimeBodyPart;
^
trail.java:9: package javax.mail.internet does not exist
import javax.mail.internet.MimeMessage;
^
trail.java:10: package javax.mail.internet does not exist
import javax.mail.internet.MimeMultipart;
^
trail.java:219: cannot find symbol
symbol : class MessagingException
location: class trail
public void sendMail(String from, String to,String subject, String messageBody)
throws MessagingException, AddressException

^
trail.java:219: cannot find symbol
symbol : class AddressException
location: class trail
public void sendMail(String from, String to,String subject, String messageBody)
throws MessagingException, AddressException

^
trail.java:232: cannot find symbol
symbol : class Session
location: class trail
Session session = Session.getDefaultInstance(props, null);
^
trail.java:232: cannot find symbol
symbol : variable Session
location: class trail
Session session = Session.getDefaultInstance(props, null);
^
trail.java:237: cannot find symbol
symbol : class MimeMessage
location: class trail
MimeMessage message = new MimeMessage(session);
^
trail.java:237: cannot find symbol
symbol : class MimeMessage
location: class trail
MimeMessage message = new MimeMessage(session);
^
trail.java:238: cannot find symbol
symbol : class InternetAddress
location: class trail
message.setFrom(new InternetAddress(from));
^
trail.java:239: package Message does not exist
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
^
trail.java:239: cannot find symbol
symbol : class InternetAddress
location: class trail
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
^
trail.java:250: cannot find symbol
symbol : class Transport
location: class trail
Transport t = session.getTransport("smtps");
^
Note: trail.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
13 errors

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
i think due to jar files

Yes, those classes you are importing are not part of the standard Java API, so you need to add the JavaMail jar files to the classpath during compilation and at runtime.

(I have removed the code you posted, it doesn't help here.)

I have also deleted your posts from the other topic where you asked this - please don't post the same question multiple times.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cant send mail using JavaMail API