Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

perchè sto smtp non mi autentica?

3 views
Skip to first unread message

rabarama

unread,
Jul 15, 2003, 11:28:09 AM7/15/03
to
Questo č il metodo che richiamo in un javabean che mi dovrebbe spedire le
emails.
tutto andava fino a quando non hanno attivato l'authenticazione sul server
SMTP.


private void sendEmail(String mailServer, String subject, String to[],
String from, String messageText) throws AddressException, MessagingException
{
Properties mailProps= new Properties();
mailProps.put("mail.smtp.host", mailServer);
mailProps.put("mail.smtp.auth","true");
Session mailSession = Session.getDefaultInstance(mailProps, null);
int toCount = to.length;
InternetAddress[] toAddrs = new InternetAddress[toCount];
for (int i = 0; i < toCount; ++i){
toAddrs[i] = new InternetAddress(to[i]);
}
InternetAddress fromAddr = new InternetAddress(from);
Message message= new MimeMessage(mailSession);
message.setFrom(fromAddr);
message.setRecipients(Message.RecipientType.TO, toAddrs);
message.setSubject(subject);
message.setContent(messageText.toString(),"text/plain");
Transport trasporto = null;
trasporto = mailSession.getTransport("smtp");
trasporto.connect(mailserver,XXXX,YYYY); //nome server, utente e password
corretti
trasporto.sendMessage(message, message.getAllRecipients());
trasporto.close();
}


mi da questo errore

javax.mail.SendFailedException: Invalid Addresses; nested exception is:
javax.mail.SendFailedException: 550 5.7.1 ... Relaying denied. Proper
authentication required.

Perchč?
Tra l'altro se lo provo da casa, pur usando il mailserver online le mail
partono, ma se uploado il tutto questo č il messaggio che ottengo.


rabarama

unread,
Jul 15, 2003, 11:38:49 AM7/15/03
to

"rabarama" <profp...@yahoo.it> ha scritto nel messaggio
news:d4VQa.34905$it4.9...@news1.tin.it...

Adesso va.
Probabilmente era qualche ipostazione non aggiornata sul server.


Federico

unread,
Jul 16, 2003, 9:59:18 AM7/16/03
to
Ciao a tutti,

sto provando ad utilizzare il package JavaMail, ed ho realizzato una
classe di prova.

Il codice è il seguente:
public sendMail() {

String smtpServer = new String("mail.libero.it");
String userId = new String("USERID");
String password = new String("PASSWORD");

Properties props = new Properties();
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.auth","true");
Session session = Session.getDefaultInstance(props, null);
try {
InternetAddress to = new InternetAddress("TO_ADDRESS");

InternetAddress from = new InternetAddress("FROM_ADDRESS");
Message message= new MimeMessage(session);
message.setFrom(from);
message.setRecipient(Message.RecipientType.TO, to);
message.setSubject("Test JavaMail");
message.setContent("Ciao Mondo","text/plain");
Transport transport = null;
transport = session.getTransport("smtp");
transport.connect(smtpServer, userId, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
catch (AddressException a) {}
catch (MessagingException m) {}

}

Sul codice non dovrebbero esserci problemi, in quanto il compilatore
esegue la classe e non dà nessun messaggio d'errore, ma le mail non
arrivano e non riesco a capire dove sta il problema!

Come MailServer SMTP ho provato ad utilizzare quello di tin
("mail.tin.it") e quello di libero ("mail.libero.it").

Qualcuno ha avuto esperienze positive utilizzando JavaMail con questi
SMTP Server? Teoricamente dovrebbe funzionare con tutti i mail server
o perlomeno con la maggior parte

Grazie

Federico

Federico

unread,
Jul 16, 2003, 10:11:53 AM7/16/03
to
Scusate,

per forza non dava messaggi d'errore, avevo lasciate vuote le clausole
catch.

Adesso il messaggio d'errore che manda è

javax.mail.NoSuchProviderException: No provider for Address type:
rfc822
at javax.mail.Session.getTransport(Session.java:516)
at javax.mail.Transport.send0(Transport.java:155)
at javax.mail.Transport.send(Transport.java:81)
at sendMail.sendMail.<init>(sendMail.java:43)
at sendMail.sendMail.main(sendMail.java:52)

Indicando quindi che non riesce a trovare il provider.

Adesso ci sbatto un pò la capoccia....

skizzo

unread,
Jul 16, 2003, 4:33:57 PM7/16/03
to
Federico <fmes...@tin.it> wrote in message news:<91mahvo18qkm4js9f...@4ax.com>...

prova così

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SimpleSendMessage{


public static void main(String args[]){

String host="mail.libero.it";
String to= "use...@mail.it";
String from= "us...@libero.it";
String subject = "prova di invio mail!!";
String msg = " Sto inviando un messaggio con java mail";


boolean sessionDebug=false;

Properties props=System.getProperties();

props.put("mail.host",host);
props.put("mail.transport.protocol","smtp");


Session session = Session.getDefaultInstance(props,null);

session.setDebug(sessionDebug);
try{
Message mex=new MimeMessage(session);
mex.setFrom(new InternetAddress(from));
InternetAddress[] address={new InternetAddress(to)};
mex.setRecipients(Message.RecipientType.TO,address);
mex.setSubject(subject);
mex.setSentDate(new Date());
mex.setText(msg);
Transport.send(mex);

}catch(Exception e){}

}
}

Federico

unread,
Jul 16, 2003, 8:13:20 PM7/16/03
to
Grazie, ho provato ma mi dà sempre errore, anzi, adesso se n'è anche
aggiunto un altro:

DEBUG: getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]
java.lang.reflect.InvocationTargetException
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at javax.mail.Session.getService(Session.java:607)
at javax.mail.Session.getTransport(Session.java:541)
at javax.mail.Session.getTransport(Session.java:484)
at javax.mail.Session.getTransport(Session.java:464)


at sendMail.sendMail.<init>(sendMail.java:43)

at sendMail.simpleSendMessage.main(simpleSendMessage.java:50)
Caused by: java.lang.NoSuchMethodError:
javax.mail.Session.getDebugOut()Ljava/io/PrintStream;
at
com.sun.mail.smtp.SMTPTransport.<init>(SMTPTransport.java:72)
... 10 more
javax.mail.NoSuchProviderException: smtp
at javax.mail.Session.getService(Session.java:611)
at javax.mail.Session.getTransport(Session.java:541)
at javax.mail.Session.getTransport(Session.java:484)
at javax.mail.Session.getTransport(Session.java:464)


at sendMail.sendMail.<init>(sendMail.java:43)

at sendMail.simpleSendMessage.main(simpleSendMessage.java:50)
Exception in thread "main"

COSA DIAVOLO POTRA' ESSERE MAI?!?!?!?

0 new messages