Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant send mail using JavaMail API

 
Jyothsna Panchagnula
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vivek Mathur
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic