Home Backend Development PHP Tutorial php使用fsockopen时,fwrite中的rn及n结束符导致,smtp.qq.com响应出现有关问题

php使用fsockopen时,fwrite中的rn及n结束符导致,smtp.qq.com响应出现有关问题

Jun 13, 2016 am 11:57 AM
com fwrite quot stream

php使用fsockopen时,fwrite中的\r\n及\n结束符导致,smtp.qq.com响应出现问题

<?php $t= time();$sk = fsockopen(&#39;tcp://smtp.qq.com&#39;,25,		$errno,		$errstr,		5);		echo "sockect ok:".(time()-$t)."\n";	if ( ! is_resource($sk) )	exit(&#39;connect error:&#39;. $errno." ".$errstr);//设置成阻塞模式 stream_set_blocking  ($sk,1);//获取初次链接信息var_dump( fgets($sk,512) );//设置读超时stream_set_timeout( $sk, 3 );var_dump( stream_get_meta_data( $sk ) );fwrite($sk,"EHLO qidizi.com\n");//这个会导致超时,个人判断应该是qq在等待一行的输入结束符,但是\n却不是,应该是\r\n才是,就会卡在这里不输出提示,这个问题,在以前的版本,及当前测试时,的163.com上面都没有发现有这个问题//fwrite($sk,"EHLO qidizi.com\r\n");//正确的一行结束符\r\n,立刻会得到响应var_dump( fgets($sk,512).&#39;:&#39;.(time()-$t) );//上面的不会超时echo "4:".(time()-$t)."\n<br />";var_dump( stream_get_meta_data( $sk ) );fclose($sk);
Copy after login

测试代码



可能qq的服务器在最近的更改中出现了变动,记得以前是可以使用\n来做为一行的结束符的,也就是一fwrite($sk,"kkk\n")就得到响应,fgets就能立刻成功,测试了一下163,\n是没有问题,最近发现qq的\n却出现问题,导致没有响应,fgets因为缓冲区没有内容导致异常,直到读超时.但是qq的换成了\r\n后就正常了.


所以smtp.qq.com,及smtp.exmail.qq.com都存在这个问题.

我开始以为是某些人说的变成了ssl的问题.却不是.现在的25端口还是可以正常使用的.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hongmeng native application random poetry Hongmeng native application random poetry Feb 19, 2024 pm 01:36 PM

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

What is the difference between comcn and com What is the difference between comcn and com May 12, 2023 pm 04:08 PM

The difference between comcn and com: 1. There are differences between comcn and com in terms of meaning, but there is no difference in access speed; 2. comcn is an international domain name and is a global top-level domain name for use by commercial institutions, while cn is a Chinese company domain name , domestic commercial institutions, domestic domain names, only enterprises can register; 3. The search priority is that cn will search for .cn first. After finding the .cn server, the .cn server will then search for .com; 4. cn is provided by cnnic China Internet Center Management, com's management organization is abroad.

How to debug Java Stream operations in IntelliJ IDEA How to debug Java Stream operations in IntelliJ IDEA May 09, 2023 am 11:25 AM

Stream operation is a highlight of Java8! Although java.util.stream is very powerful, there are still many developers who rarely use it in actual work. One of the most complained reasons is that it is difficult to debug. This was indeed the case at the beginning, because streaming operations such as stream cannot be used in DEBUG When it is one line of code, when it comes to the next step, many operations are actually passed at once, so it is difficult for us to judge which line in it is the problem. Plug-in: JavaStreamDebugger If the IDEA version you are using is relatively new, this plug-in is already included and does not need to be installed. If it is not installed yet, install it manually and then continue below.

How to get max value from stream in java8 How to get max value from stream in java8 May 14, 2023 pm 03:43 PM

java8's stream takes maxpublicstaticvoidmain(String[]args){Listlist=Arrays.asList(1,2,3,4,5,6);Integermax=list.stream().max((a,b)->{if (a>b){return1;}elsereturn-1;}).get();System.out.println(max);}Note: The size is determined here through positive and negative numbers and 0 values. Instead of writing it directly if(a>b){returna;}elseretur

How to use fopen, fwrite and fclose in php for file operations? How to use fopen, fwrite and fclose in php for file operations? Jun 01, 2023 am 08:46 AM

In PHP development, file operations are very common. Under normal circumstances, we need to perform file reading, writing, deletion and other operations. Among them, the fopen function and fread function can be used to read the file, and the fopen function, fwrite function and fclose function can be used to write the file. This article will introduce how PHP uses fopen, fwrite and fclose to perform file operations. 1. fopen function The fopen function is used to open files. Its syntax is as follows: r

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

How the Java Stream API makes your code better How the Java Stream API makes your code better May 14, 2023 pm 06:22 PM

Preface JavaStream is a powerful data processing tool that can help developers process and transform data streams quickly and efficiently. Using Stream operations can greatly simplify the code, making it more readable and maintainable, thereby improving development efficiency. filter(): retain elements that meet the conditions based on the specified Predicate. map(): Maps each element according to the specified Function and generates a new Stream. flatMap(): Maps each element to a Stream, and then concatenates these Streams into a Stream. distinct(): Returns a deduplicated Stream. sorted(): for Stre

Is Microsoft introducing trimmed video in Microsoft Stream (on SharePoint)? Here's what the new roadmap update says Is Microsoft introducing trimmed video in Microsoft Stream (on SharePoint)? Here's what the new roadmap update says Nov 24, 2023 pm 11:13 PM

In an updated entry on the Microsoft 365 Roadmap website (Feature ID: 186956), the Redmond-based tech giant said the feature will give users editing permissions to trim the beginning, end, and any clips in a video. "When you trim a video, Stream does not change the original video file itself. Instead, it simply hides the trimmed portion from the viewer," the update reads. You can then try out this feature by launching a video in the StreamWeb app and clicking the edit button once the rollout is complete over the next few months. The roadmap update states that the rollout will begin in "March 2023." However, given that the roadmap entry was added on November 21, 2023

See all articles