Using SMTP, Gmail, and STARTTLS
来源:互联网 发布:淘宝网网站需求分析 编辑:程序博客网 时间:2024/06/01 08:52
So I'm learning about SMTP and am trying to use telnet
to send some mail over SMTP.
I've easilly been able to send mail to my gmail account via:
$ host gmail.com...gmail.com mail is handled by 5 gmail-smtp-in.l.google.com....$ telnet gmail-smtp-in.l.google.com 25Trying 74.125.142.27......Connected to gmail-smtp-in.l.google.com....HELO <me@test.com>...
However, I'm having trouble sending from my gmail account. From what I understand about SMTP, I should be using SMTP to send mail from < mygmailaddress@gmail.com > to the outgoing gmail SMTP servers, which in turn use SMTP to transfer the mail to the receivers incoming SMTP server ect.
However, I'm having difficulties. If I telnet
into smtp.gmail.com
via port465
(gmail outgoing smtp mail server canonical), I'm immediately disconnected after starting withHELO <blah@blah.com>
, or asked to STARTTLS
. I can't find answers on how to proceed.
Any help is appreciated.
Sidenote: Currently I'm using Starbucks free Wi-Fi to access the internet. I'm actually unable totelnet
directly from my computer (No route to host error). Instead, it only works if Issh
into a remote linux box on my school's network first, then telnet
from there. Any idea why this is?
Thanks!
First of all, it looks like you're using the wrong port. Gmail exposes port 465 for SMTP over SSL and port 587 for SMTP with STARTTLS, asdocumented here. The difference between these two is that SMTP over SSL first establishes a secure SSL/TLS connection and conducts SMTP over that connection, and SMTP with STARTTLS starts with unencrypted SMTP and then switches to SSL/TLS. This is why you don't get a response to your HELO.
$ telnet smtp.gmail.com 587Trying 74.125.25.108...Connected to gmail-smtp-msa.l.google.com.Escape character is '^]'.220 mx.google.com ESMTP fr1sm24834956pbb.26 - gsmtpHELO <me@test.com>250 mx.google.com at your serviceSTARTTLS220 2.0.0 Ready to start TLS
But even if you telnet to port 587 you still aren't going to be able to send any email by hand. In order to do anything interesting you will have toSTARTTLS, and you won't be able to handle theSSL/TLS binary protocol to negotiate the encryption.
The telnet client will not negotiate a TLS session for you. You should use another tool, such as OpenSSL's s_client. The following issues the STARTTLS command for you and handles the TLS negotiation:
$ openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf
Alternatively, you could connect directly to the SMTPS port:
$ openssl s_client -connect smtp.gmail.com:465 -crlf
- Using SMTP, Gmail, and STARTTLS
- SMTP starttls选项
- Send mail using Gmail SMTP in Magento
- Gmail SMTP example
- gmail smtp使用注意事项
- Gmail smtp 错误 534 解决
- Send Email Using Gmail
- gmail的 smtp就变态在这里!!
- ASP.NET与GMail免费SMTP服务器
- jmail 4.5使用gmail smtp ssl解决方法
- Drupal中使用gmail配置SMTP
- Configuring GMail for Outgoing Mail (SMTP)
- 用 Gmail 的 SMTP 发送邮件
- 如何使用GMAIL的SMTP发送邮件
- openssl使用SMTP向gmail发送邮件
- Gmail的smtp端口465和587
- Gmail的smtp端口465和587
- 用 Gmail 的 SMTP 发送邮件
- 感受
- wxPython结合cocos2d-x开发编辑器
- ios初学SQLite3(创建、插入、查询、更新数据库和表)
- windows核心编程学习日记-字符和字符串处理 上篇
- <meta name="name" content="string">
- Using SMTP, Gmail, and STARTTLS
- GNU C函数嵌套定义及闭包
- spring security3.x学习(20)_初探authorize标签和第四个例子
- UDP:socket服务端和接收端的基本使用实例
- 使用强制性的手段来结束一个进程
- LeetCode:Single Number II
- 算法导论-----------------0-1背包问题dp求解
- 百练 2574(八皇后DFS)
- QT vs2008 配置