php如何验证smtp信息的正确
Jun 23, 2016 pm 02:05 PM最近在用dede做站,看到后台有启用smtp方式发送邮件的设置,但没有验证。请问各位PHP大神,如何验证填写的smtp信息是否正确,验证包括端口、用户名、密码?求php代码实现,并输出这些错误信息,100分奉上!感谢。
回复讨论(解决方案)
dede的启用smtp方式发送邮件的设置,你是安装的插件吗?
我本地装的最新dede好像没这个功能设置哦
回楼上大牛,我只要能验证smtp信息是否正确就行,不需要做成dede插件。
//打开smtp服务器端口
$fp = @fsockopen($smtp_host, 25);
if (!$fp)
echo "Error: Cannot conect to ".$smtp_host."
";
1 |
|
倒没有没弄过验证smtp的端口、用户名、密码,端口还好说,但用户名、密码的话,只能尝试去请求来判断了...
function smtp_sockopen_relay()
{
$this->log_write("Trying to ".$this->relay_host.":".$this->smtp_port."\n");
$this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok()))
{
$this->log_write("Error: Cannot connenct to relay host ".$this->relay_host."\n");
$this->log_write("Error: ".$errstr." (".$errno.")\n");
return FALSE;
}
$this->log_write("Connected to relay host ".$this->relay_host."\n");
return TRUE;;
}

熱門文章

熱門文章

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)