vs ssl://使用Gmail邮件服务器发送电子邮件 [英] vs ssl:// while sending email using gmail smtp server

本文介绍了 vs ssl://使用Gmail邮件服务器发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!



Gmail SMTP服务器也可用于转发来自
SMTP,SSL / TLS连接到Gmail邮件服务器。如果您使用SMTP连接,则只能将邮件发送到
Gmail或Google Apps用户;如果您使用SSL / TLS连接,则可以将

如果您的设备或应用程序支持SSL,请连接到 $


无法使用PHP SMTP发送电子邮件。您的服务器可能不是


当我使用ssl: //也在端口465上,我的应用程序现在可以正常工作。

  • ssl:// smtp有什么区别。 gmail.com和,如果后者也使用ssl?

  • 为什么我们无法将电子邮件发送到没有SSL的其他域?这只是由gmail出于安全目的完成的吗?



主机名前缀与 ssl:/ / ,没有它是基础流是否包装 a>通过OpenSSL,或以纯文本方式发言。


当您使用 ssl:// 封装器连接到支持TLS或SSL的服务时,PHP对您来说很神奇。它允许你读取和写入数据流(使用fread / fwrite),就像你使用未加密的连接一样,所有的握手,加密和解密都是在背景中完成的,但不得超过主机前缀与ssl包装。


通过阅读SMTP协议, STARTTLS 命令以及一般TLS加密,您可以了解有关第一个问题的更多信息。 STARTTLS 允许客户端通过未加密的连接连接到邮件服务器,然后协商(升级)连接以使用加密,另一方面,端口465的连接期望一旦建立连接并且发生任何协议(SMTP)通信之前,就会发生TLS握手。

According to this

Gmail SMTP Server could also be used to relay messages from your device or application. You can connect to Gmail mail servers using SMTP, SSL/TLS. If you connect using SMTP, you can only send mail to Gmail or Google Apps users; if you connect using SSL/TLS, you can send mail to anyone.

If your device or application supports SSL - connect to on port 465.

So I tried connecting to on port 465. I got the following error:

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

Some code uses another address "ssl://".

When I use ssl:// also on port 465, my application now works correctly.

  • What's the difference between ssl:// and if the latter also uses ssl?
  • Why can't we send emails to other domains without SSL? Is this only done by gmail for security purposes?

I am extremely new at this. Can anyone explain? I am using php if it matters.


The difference between the prefixing the hostname with ssl:// and without it is whether or not the underlying stream will be wrapped through OpenSSL, or speak in plain text.

When you connect to Gmail on port 465, it expects the client will use TLS encryption. Most likely, the error message you were seeing was a general result of connecting to a service expecting an encrypted connection when it was just trying to write and read data in plain text.

PHP does magic for you when you use the ssl:// wrapper to connect to a service that supports TLS or SSL. It allows you to read and write on the stream (using say fread/fwrite) in the same manner you would on an unencrypted connection and all the handshaking, encryption, and decryption is done in the background having to do no more than prefix the host with the ssl wrapper.

As to the second question, it is most likely security related. In order to relay (send mail to another domain) you need to authenticate over SMTP which should NEVER be done in cleartext while you can connect on port 25 using an unencrypted connection and send mail to a Gmail user without authenticating (this is what most outside mail servers do when one of their users which to send mail to Gmail). But technologically, there's nothing preventing them from allowing you to send mail using an unencrypted connection, or even authenticating with Gmail credentials (this is called an open relay and is usually badly abused by spammers).

You can learn more about your first question by just reading about the SMTP protocol, the STARTTLS command, and TLS encryption in general. STARTTLS allows a client to connect to the mail server over an unencrypted connection and then negotiate (upgrade) the connection to use encryption, where on the other hand, connections to port 465 expect a TLS handshake to occur as soon as the connection is established and before any protocol (SMTP) communication occurs.

这篇关于 vs ssl://使用Gmail邮件服务器发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
发送“验证码”获取 | 15天全站免登陆