nguyen_85
asked on
JavaMail
I'm trying to use the JavaMail to send and receive message through my yahoo account which has pop3 and smtp but I keep getting this error:
"javax.mail.MessagingExcep tion: 530 authentication required ".
How do I set this authentication on my code?
Below is the code that I use:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host" , "smtp.mail.yahoo.com");
Session s = Session.getInstance(props) ;
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("myemailad dress@yaho o.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("myemailad dress@yaho o.com");
message.addRecipient(Messa ge.Recipie ntType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
// Next two lines are specific to Yahoo
Store store = s.getStore("pop3");
store.connect("pop.mail.ya hoo.com", "my_username", "my_password");
Transport.send(message);
// Next line is specific to Yahoo
store.close();
%>
Thanks!
"javax.mail.MessagingExcep
How do I set this authentication on my code?
Below is the code that I use:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host"
Session s = Session.getInstance(props)
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("myemailad
message.setFrom(from);
InternetAddress to = new InternetAddress("myemailad
message.addRecipient(Messa
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
// Next two lines are specific to Yahoo
Store store = s.getStore("pop3");
store.connect("pop.mail.ya
Transport.send(message);
// Next line is specific to Yahoo
store.close();
%>
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes sorry, they are username and password.
ASKER
Sorry object, now i get this error:
javax.servlet.ServletExcep tion: Sending failed;
nested exception is:
javax.mail.SendFailedExcep tion: Invalid Addresses;
nested exception is:
javax.mail.SendFailedExcep tion: 550 5.7.1 Unable to relay for nguyen_8585@yahoo.com
my codes below:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.auth" , "true");
Authenticator auth = new com.wrox.authentication.SM TPAuthenti cator();
Session s = Session.getDefaultInstance (props, auth);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("my_yahoo_ address.co m");
message.setFrom(from);
InternetAddress to = new InternetAddress("my_yahoo_ address.co m");
message.addRecipient(Messa ge.Recipie ntType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
// Next two lines are specific to Yahoo
Store store = s.getStore("pop3");
store.connect("pop.mail.ya hoo.com", "my_username", "mypassword");
Transport.send(message);
// Next line is specific to Yahoo
store.close();
%>
javax.servlet.ServletExcep
nested exception is:
javax.mail.SendFailedExcep
nested exception is:
javax.mail.SendFailedExcep
my codes below:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.auth"
Authenticator auth = new com.wrox.authentication.SM
Session s = Session.getDefaultInstance
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("my_yahoo_
message.setFrom(from);
InternetAddress to = new InternetAddress("my_yahoo_
message.addRecipient(Messa
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
// Next two lines are specific to Yahoo
Store store = s.getStore("pop3");
store.connect("pop.mail.ya
Transport.send(message);
// Next line is specific to Yahoo
store.close();
%>
Does your mail server allow relaying?
where do you specify the smtp server?
ASKER
sorry, How do I find out if my mail server allow relaying? I'm just using the free yahoo mail account accept I bought the upgrade in order to use the pop3 and smtp.
that error tends to indicate that relaying is not supported.
make sure your from address is your valid address.
ASKER
Do you know any site that offer this feature so I can test my JavaMail. It's for a school project. I raise up your point to 450 for you trouble.
Thanks!
Thanks!
what is the name of the server you are currently using?
ASKER
I don't know if this make any sense, but I'm using the server on yahoo on the the regular email account that you get for free. I think it's call
pop.mail.yahoo.com(for pop3) and smtp.mail.yahoo.com(fpr smtp).
pop.mail.yahoo.com(for pop3) and smtp.mail.yahoo.com(fpr smtp).
> and smtp.mail.yahoo.com(fpr smtp).
where do u specify that in your code?
Can you send mail using that server from other mail programs (outlook, eudora etc)
where do u specify that in your code?
Can you send mail using that server from other mail programs (outlook, eudora etc)
ASKER
I can send mail using that server from programs like outlook.
The code that I used:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.auth" , "smtp.mail.yahoo.com");
//I create a class that you wrote
Authenticator auth = new com.wrox.authentication.SM TPAuthenti cator();
Session s = Session.getDefaultInstance (props, auth);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("nguyen_85 85@yahoo.c om");
message.setFrom(from);
InternetAddress to = new InternetAddress("nguyen_85 85@yahoo.c om");
message.addRecipient(Messa ge.Recipie ntType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
// Next two lines are specific to Yahoo
Store store = s.getStore("pop3");
store.connect("pop.mail.ya hoo.com", "my"_user_name, "my_pass_word");
Transport.send(message);
// Next line is specific to Yahoo
store.close();
%>
The code that I used:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.auth"
//I create a class that you wrote
Authenticator auth = new com.wrox.authentication.SM
Session s = Session.getDefaultInstance
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("nguyen_85
message.setFrom(from);
InternetAddress to = new InternetAddress("nguyen_85
message.addRecipient(Messa
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
// Next two lines are specific to Yahoo
Store store = s.getStore("pop3");
store.connect("pop.mail.ya
Transport.send(message);
// Next line is specific to Yahoo
store.close();
%>
try using the following properties:
Properties props = new Properties();
props.put("mail.smtp.host" , "smtp.mail.yahoo.com");
props.put("mail.smtp.auth" , "true");
Properties props = new Properties();
props.put("mail.smtp.host"
props.put("mail.smtp.auth"
ASKER
Thanks a million objects it works! I raise your points to 500. I needed this code!
ASKER
Thanks!