Tuesday, May 28, 2013

Java email : connect to Gmail fail


# Problem:

[28/05/2013 10:11:41.033][INFO]--+++ Java Mail:MessagingException
[28/05/2013 10:11:41.034][INFO]--??? ->javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
java.net.ConnectException: 連線被拒絕


#Copy Ans:
http://www.coderanch.com/t/416516/java/java/connect-SMTP-host-localhost-port

The question is the same: 
Do you have an SMTP server running on localhost on port 25? If so, check its log files for messages. If not, then that's your problem.

#
http://blog.longwin.com.tw/2010/09/google-gmail-set-value-2010/
Google Gmail 得 IMAP, SMTP, POP3 得設定值, 整理如下:

http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm


#Problem:

#

javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
  nested exception is:
java.net.ConnectException: 連線被拒絕


Could not connect to SMTP host: smtp.gmail.com, port: 465;
  nested exception is:
java.net.ConnectException: 連線被拒絕


解答:
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/




#Problem:

#openssl s_client -host smtps.gmail.com -port 465
gethostbyname failure
connect:errno=110


#官方文件
https://support.google.com/mail/answer/13287?hl=en




#imap works :
openssl s_client -crlf -connect imap.gmail.com:993''

http://www.tannerjepsen.com/posts/imap-ssl-using-openssl-on-gmail

#step by step: IMAP works.
http://delog.wordpress.com/2011/05/10/access-imap-server-from-the-command-line-using-openssl/

#how to setup ssl squid3 for smtp.gmail.com

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
#acl localnet src fc00::/7       # RFC 4193 local private network range
#acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT


Squid3的設定:

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports





#Squid3 log:

Squid Proxy Sever View logs / log files




No comments:

Post a Comment