DianaPJ 12 de mar. de 2007
eu tenho uma implementação parecido com essa…
a diferença é que sempre uso autenticação (login e senha)…
já testou enviar e-mail com autenticação???
t+
teofiloPJ 12 de mar. de 2007
aqui vai um codigo de autenticação
public class SMTPAutenticador extends Authenticator & # 123 ;
private static final String user = & quot ; joselito & quot ;;
private static final String password = & quot ; 123 abc & quot ;;
private static final PasswordAuthentication rfPasswordAuthentication = new PasswordAuthentication & # 40 ; user , password & # 41 ;;
public static final SMTPAutenticador rfAutenticador = new SMTPAutenticador & # 40 ; & # 41 ;;
private SMTPAutenticador & # 40 ; & # 41 ; & # 123 ; & # 125 ;
public PasswordAuthentication getPasswordAuthentication & # 40 ; & # 41 ; & # 123 ;
return rfPasswordAuthentication ;
& # 125 ;
& # 125 ;
VijavaPJ 13 de mar. de 2007
Session session = Session . getDefaultInstance & # 40 ; props , new Authenticator & # 40 ; & # 41 ; & # 123 ;
protected PasswordAuthentication getPasswordAuthentication & # 40 ; & # 41 ; & # 123 ;
return new PasswordAuthentication & # 40 ; "[email removido]" , "senha" & # 41 ;; & # 125 ; & # 125 ;
& # 41 ;;
usei isso para tentar autenticar mas deu esses erros
DEBUG & # 58 ; setDebug & # 58 ; JavaMail version 1.4 ea
DEBUG & # 58 ; getProvider & # 40 ; & # 41 ; returning javax . mail . Provider & # 91 ; TRANSPORT , smtp , com . sun . mail . smtp . SMTPTransport , Sun Microsystems , Inc & # 93 ;
DEBUG SMTP & # 58 ; useEhlo true , useAuth true
DEBUG SMTP & # 58 ; useEhlo true , useAuth true
DEBUG SMTP & # 58 ; trying to connect to host "smtp.gmail.com" , port 25 , isSSL false
220 mx . google . com ESMTP i20sm10452834wxd
DEBUG SMTP & # 58 ; connected to host "smtp.gmail.com" , port & # 58 ; 25
EHLO organiza
250 - mx . google . com at your service , & # 91 ; 200.216.156.232 & # 93 ;
250 - SIZE 20971520
250-8 BITMIME
250 - STARTTLS
250 ENHANCEDSTATUSCODES
DEBUG SMTP & # 58 ; Found extension "SIZE" , arg "20971520"
DEBUG SMTP & # 58 ; Found extension "8BITMIME" , arg ""
DEBUG SMTP & # 58 ; Found extension "STARTTLS" , arg ""
DEBUG SMTP & # 58 ; Found extension "ENHANCEDSTATUSCODES" , arg ""
DEBUG SMTP & # 58 ; use8bit false
MAIL FROM & # 58 ; & lt ;[ email removido ] & gt ;
530 5.7.0 Must issue a STARTTLS command first i20sm10452834wxd
com . sun . mail . smtp . SMTPSendFailedException & # 58 ; 530 5.7.0 Must issue a STARTTLS command first i20sm10452834wxd
at com . sun . mail . smtp . SMTPTransport . issueSendCommand & # 40 ; SMTPTransport . java & # 58 ; 1388 & # 41 ;
at com . sun . mail . smtp . SMTPTransport . mailFrom & # 40 ; SMTPTransport . java & # 58 ; 959 & # 41 ;
at com . sun . mail . smtp . SMTPTransport . sendMessage & # 40 ; SMTPTransport . java & # 58 ; 583 & # 41 ;
at javax . mail . Transport . send0 & # 40 ; Transport . java & # 58 ; 169 & # 41 ;
at javax . mail . Transport . send & # 40 ; Transport . java & # 58 ; 98 & # 41 ;
at TrataEnvioRecebimento . Envio . EnviarMensagem & # 40 ; Envio . java & # 58 ; 60 & # 41 ;
at telas . Principal . actionPerformed & # 40 ; Principal . java & # 58 ; 328 & # 41 ;
at javax . swing . AbstractButton . fireActionPerformed & # 40 ; AbstractButton . java & # 58 ; 1849 & # 41 ;
at javax . swing . AbstractButton$Handler . actionPerformed & # 40 ; AbstractButton . java & # 58 ; 2169 & # 41 ;
at javax . swing . DefaultButtonModel . fireActionPerformed & # 40 ; DefaultButtonModel . java & # 58 ; 420 & # 41 ;
at javax . swing . DefaultButtonModel . setPressed & # 40 ; DefaultButtonModel . java & # 58 ; 258 & # 41 ;
at javax . swing . plaf . basic . BasicButtonListener . mouseReleased & # 40 ; BasicButtonListener . java & # 58 ; 234 & # 41 ;
at java . awt . Component . processMouseEvent & # 40 ; Component . java & # 58 ; 5488 & # 41 ;
at javax . swing . JComponent . processMouseEvent & # 40 ; JComponent . java & # 58 ; 3126 & # 41 ;
at java . awt . Component . processEvent & # 40 ; Component . java & # 58 ; 5253 & # 41 ;
at java . awt . Container . processEvent & # 40 ; Container . java & # 58 ; 1966 & # 41 ;
at java . awt . Component . dispatchEventImpl & # 40 ; Component . java & # 58 ; 3955 & # 41 ;
at java . awt . Container . dispatchEventImpl & # 40 ; Container . java & # 58 ; 2024 & # 41 ;
at java . awt . Component . dispatchEvent & # 40 ; Component . java & # 58 ; 3803 & # 41 ;
at java . awt . LightweightDispatcher . retargetMouseEvent & # 40 ; Container . java & # 58 ; 4212 & # 41 ;
at java . awt . LightweightDispatcher . processMouseEvent & # 40 ; Container . java & # 58 ; 3892 & # 41 ;
at java . awt . LightweightDispatcher . dispatchEvent & # 40 ; Container . java & # 58 ; 3822 & # 41 ;
at java . awt . Container . dispatchEventImpl & # 40 ; Container . java & # 58 ; 2010 & # 41 ;
at java . awt . Window . dispatchEventImpl & # 40 ; Window . java & # 58 ; 1774 & # 41 ;
at java . awt . Component . dispatchEvent & # 40 ; Component . java & # 58 ; 3803 & # 41 ;
at java . awt . EventQueue . dispatchEvent & # 40 ; EventQueue . java & # 58 ; 463 & # 41 ;
at java . awt . EventDispatchThread . pumpOneEventForHierarchy & # 40 ; EventDispatchThread . java & # 58 ; 242 & # 41 ;
at java . awt . EventDispatchThread . pumpEventsForHierarchy & # 40 ; EventDispatchThread . java & # 58 ; 163 & # 41 ;
at java . awt . EventDispatchThread . pumpEvents & # 40 ; EventDispatchThread . java & # 58 ; 157 & # 41 ;
at java . awt . EventDispatchThread . pumpEvents & # 40 ; EventDispatchThread . java & # 58 ; 149 & # 41 ;
at java . awt . EventDispatchThread . run & # 40 ; EventDispatchThread . java & # 58 ; 110 & # 41 ;
QUIT
221 Closing connection . Good bye .
ERRO = 530 5.7.0 Must issue a STARTTLS command first i20sm10452834wxd
VijavaPJ 13 de mar. de 2007
vou tentar usar essa autenticacao
VijavaPJ 15 de mar. de 2007
props . put & # 40 ; "mail.smtp.starttls.enable" , "true" & # 41 ;;
coloquei isso no codigo
acabou com os erros em cima
mas agora ta falando q to enviando uma mensagem protegida.
ai da erro e num envia o email
alguem sabe o q faco agora?
VijavaPJ 15 de mar. de 2007
props . put & # 40 ; "mail.smtp.starttls.enable" , "true" & # 41 ;;
coloquei isso no codigo
acabou com os erros em cima
mas agora ta falando q to enviando uma mensagem protegida.
ai da erro e num envia o email
alguem sabe o q faco agora?
marcossousaPJ 15 de mar. de 2007
tente assim:
props.put("mail.smtp.auth", "true");
message.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect(host, usuario, senha);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
:okok:
VijavaPJ 15 de mar. de 2007
marcossousa
cara sua implementacao quase funcionou mas deu um pequeno erro no meu ip
550 <unknown[111.222.33.44]>: Client host rejected: Access denied. Invalid network.
deu o erro acima, será que é q eu uso net discada?
o ip eu troquei né
marcossousaPJ 16 de mar. de 2007
ué,
acho que o gmail tem uma porta específica para envio. Tente colocar:
p . put & # 40 ; "mail.smtp.port" , "465" & # 41 ;;
:okok: