- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 telnet 和 php 进行邮件验证。整个过程在终端中很好,但是当我使用 php shell_exec()
时,它只运行到 Telnet 连接命令。连接 telnet 后,其余的 telnet 特定命令将不再起作用。
我们需要使用其他方式使用 php 执行 telnet 吗?
更新:我正在尝试复制 this教程。
这是我的代码
public function mailtest(Request $request){
//Taking input email
$email = $request->input("email");
$divide = explode("@", $email);
//Find out the Domain
$server = $divide[1];
$response = shell_exec("nslookup -q=mx $server");
//Response of the nslookup
print_r($response);
$mailServerList = explode(PHP_EOL, $response);
$line = $mailServerList[4];
$serverArr = preg_split('/\s+/', $line);
$n = sizeof($serverArr);
$mailServer = $serverArr[$n-1];
//Printing out the mail server out of the nslookup response
print_r($mailServer);
//Executing Telnet command
$telnet = shell_exec("telnet $mailServer 25");
print_r("telnet response ".$telnet);
//Telnet Helo
$helo = shell_exec("Helo testing.com");
print_r("Helo response ".$helo);
//Telnet mail from
$from = shell_exec('mail from: testing@gmail.com');
print_r("MAil from response ".$from);
//Telnet RCPT to
$finalResponse = shell_exec("rcpt to: $email");
print_r("Mail to response ".$finalResponse);
}
这是回复
Server: 10.0.80.11
Address: 10.0.80.11#53
Non-authoritative answer:
gmail.com mail exchanger = 5 gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail exchanger = 20 alt2.gmail-smtp-in.l.google.com.
Authoritative answers can be found from:
gmail-smtp-in.l.google.com internet address = 173.194.64.27
gmail-smtp-in.l.google.com has AAAA address 2607:f8b0:4003:c02::1a
alt1.gmail-smtp-in.l.google.com internet address = 173.194.219.27
alt1.gmail-smtp-in.l.google.com has AAAA address 2607:f8b0:4002:c03::1b
alt4.gmail-smtp-in.l.google.com internet address = 64.233.190.26
alt4.gmail-smtp-in.l.google.com has AAAA address 2800:3f0:4003:c01::1b
alt3.gmail-smtp-in.l.google.com internet address = 74.125.141.26
alt3.gmail-smtp-in.l.google.com has AAAA address 2607:f8b0:400c:c06::1a
alt2.gmail-smtp-in.l.google.com internet address = 173.194.205.27
alt2.gmail-smtp-in.l.google.com has AAAA address 2607:f8b0:400d:c02::1b
gmail-smtp-in.l.google.com.telnet response Trying 2607:f8b0:4003:c02::1a...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
Helo response
MAil from response No message, no subject; hope that's ok
Mail to response
最佳答案
shell_exec 不适合那个(参见 Ulrich 的解释)。
fsockopen
应该可以解决问题。
$fp = @fsockopen('yourMailServer.com', 9001);
if ($fp) {
fwrite($fp, "username\n");
fwrite($fp, "password\n");
while ($line = fread($fp, 2048)) {
// do things with $line
}
} else {
//return error
}
关于php - 无法使用 PHP shell_exec() 执行 telnet 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33952352/
我一直在尝试创建一个 expect 脚本来通过 telnet 自动登录到我的设备 如果expect 命令没有多种可能性,则脚本可以正常工作,登录设备。 #!/usr/bin/expect set ti
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
据我了解,Telnet 与 HTTP 一样都是一种协议(protocol)。我有这样的想法,在建立初始 TCP 连接后,Telnet 客户端会将一些 telnet 特定代码发送到另一端的服务器(在本例
我正在尝试使用 C++ 和 QT 作为 GUI 来实现 Telnet 客户端。我不知道如何处理 telnet 协商。每个 telnet 命令都以 IAC 开头,例如 IAC WILL SUPPRESS
我需要在 telnet 中进行大量测试。我正在研究一些方法来自动检测我们电子邮件服务器上的字典攻击,然后限制它们,或将它们列入黑名单等。 我现在准备运行一些测试,看看我的工作是否有返回。我想我只需下载
看来您应该能够使用 telnet 手动进行 json-rpc 调用。但是,当我尝试这样做时,服务器根本没有任何响应,我不得不关闭 telnet 客户端。我是否需要发送 header 和/或以某种方式表
看来您应该能够使用 telnet 手动进行 json-rpc 调用。但是,当我尝试这样做时,服务器根本没有任何响应,我不得不关闭 telnet 客户端。我是否需要发送 header 和/或以某种方式表
我正在使用来自 busy-box 的 Telnet 客户端。我需要与 telnet 服务器创建一个 session ,但需要根据特定条件从 C 代码创建 session ,一旦创建 session ,
我需要发出 telnet close 命令,通常,^] (Ctrl-]) 应该可以工作。(找不到任何 emacs 特定的 telnet 文档) 我怎样才能得到 telnet>当我在 emacs 中使用
几天前我买了一个新的 MTS Wi-Fi Dongle,今天在使用它时,我使用我的 Android 设备在 192.168.1.1 上进行了端口扫描,令人惊讶的是端口 23(telnet)是开放的。输
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我有一个项目要做,它是这样的: 当您打开一个 telnet 控制台并 telnet 到我的服务器时,PHP 应该响应:“你好,你叫什么名字?” 然后你输入你的名字等等。我怎样才能在 PHP 中做到这一
是否可以通过 telnet 连接到服务器并从那里 telnet 到 python 中的另一台服务器?由于有一个 Controller ,我使用用户名和密码远程登录,并且从 Controller 命令行
我选择了一个用 C 编写 Telnet 服务器和 Telnet 客户端代码的项目。我正在学习 C 编程。 有没有人尝试过这个。请告诉我如何进行以及要引用的 Material 。抱歉询问源代码。我不知道
我需要编写一个在 Windows 上运行的 Perl 脚本,以通过远程登录到 Linux 机器来不断监视 Linux 机器下的日志文件以寻找模式。但问题是,Linux 机器非常频繁地重新启动(通过一些
我是 python 新手,我正在编写一个脚本来在某些情况下“telenet”设备 IP,如果 telnet 失败则编写 SSH username@deviceIp.. 对于所有 Telnet IP,它
我正在使用 org.apache.commons.net.telnet 库与我的 Telnet 服务器建立连接,该服务器的实现与标准 RFC 854 略有不同,但没什么太可怕的。 实际上,我建立到此远
我正在使用 org.apache.commons.net.telnet 库与我的 Telnet 服务器建立连接,该服务器的实现与标准 RFC 854 略有不同,但没什么太可怕的。 实际上,我建立到此远
我的要求是从 Node js连接到Telnet客户端。 我正在使用 telnet-client包裹 我正在使用此代码进行连接 var Telnet = require('telnet-client')
我需要一个 expect 脚本来等待发出的命令完成,然后从 telnet 注销。这是脚本: spawn telnet host send "username\r" send "password\r"
我是一名优秀的程序员,十分优秀!