Vorrei inviare dei messaggi tramite un'applicazione java. Ho creato questa classe, ma cosa sbaglio? Non invia niente a yahoo mail.
riguardo a yahoo ho trovato questo: clicca quicodice:import java.util.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class Invio { public static void main(String[] args) { String to="prova@yahoo.it"; String from="prova@yahoo.it"; String host="smtp.mail.yahoo.com"; Properties props = new Properties(); props.put("mail.smtp.host",host); props.put("mail.debug","true"); Session session=Session.getInstance(props); try { Message msg=new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address ={new InternetAddress(to)}; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject("An Hello World e-mail!"); msg.setSentDate(new Date()); msg.setText("Hello world!"); Transport.send(msg); } catch (MessagingException mex) { mex.printStackTrace(); } } }
Gli errori che mi dice sono:
com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(S MTPTransport.java:2057)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTrans port.java:1580)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTr ansport.java:1097)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at Invio.main(Invio.java:24)
at __SHELL1.run(__SHELL1.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at bluej.runtime.ExecServer$3.run(ExecServer.java:724 )

Rispondi quotando