|
file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。
Error File: \admin\app\template.app.php at 285 line.
report_issue
返回上一页
php_network_getaddresses: getaddrinfo failed
这个错误一般发生在有远程请求时,典型的错误信息是:
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed:Name or service not known in /home/carstyling/public_html/newnuke/modules/WebMail/pop3.php on line 70
Warning: fsockopen(): unable to connect to mx.freenet.de:110 in /home/carstyling/public_html/newnuke/modules/WebMail/pop3.php on line 70
这个问题并不是PHP的问题,而是出在域名解析环节。
可以修改/etc/resolv.conf,更改自己的域名解析服务器
或者自己在/etc/hosts中设置需要链接的位置
完成后重新刷新页面,这个错误就不会发生了。
该错误为服务器没配置dns。导致 file_get_content 中找不到要抓取的域名地址
linux 设置dns
[root@dzsw ~]# vi /etc/resolv.conf
nameserver 192.88.88.98
nameserver 61.144.56.101
/etc/rc.d/init.d/named restart
也可以配置/etc/hosts
比如,我们要抓取www.baidu.com的东西
C:\Documents and Settings\Administrator>ping www.baidu.com
Pinging www.a.shifen.com [202.108.22.5] with 32 bytes of data:
Reply from 202.108.22.5: bytes=32 time=21ms TTL=53
Reply from 202.108.22.5: bytes=32 time=23ms TTL=53
则我们可以 vi /etc/hosts
www.baidu.com 202.108.22.5
如此一来,在linux机器ping www.baidu.com可以得到 202.108.22.5了,
则 file_get_content www.baidu.com中的东西,由于已经可以找到,不会报错,
不过此时 file_get_content 其他网站还是会报错,但这个方法有个好处就是,代码只能
file_get_content我们在/etc/hosts写好的几个,如果被注射js木马,则js木马由于不能访问到它想访问的地方
等于无效了
phpmailer异常 php_network_getaddresses: getaddrinfo failed:
你的位置:IT资料网 >> IT智库 >> 网站相关 >> php2 >> 详细内容 在线投稿
phpmailer异常 php_network_getaddresses: getaddrinfo failed:
发布: 2009-1-06 15:21 | 作者: 本站整理 | 来源: 网络转载 | 查看: 8次
我用smarty模板,发邮件的时候,我在localhost上测试的时候是可以通过的。
同样地代码,传到公司的服务器上,会抛异常:
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /server/application/backadmin/class/class.smtp.php on line 105
Warning: fsockopen() [function.fsockopen]: unable to connect to MAIL_HOST:25 (Unknown error) in /server/application/backadmin/class/class.smtp.php on line 105
Message could not be sent.
Mailer Error: Language string failed to load: connect_host
其中MAIL_HOST是我定义的一个常量,值是smtp邮件服务器地址。
在网上查资料,说是有可能是域名没有解析。
我在phpmailer的两个文件phpmailer和smtp里面找没找到哪里可以设置DNS地址的。
这个错误应该如何解决?
---------回复--------------
我今天调试的时候也出现相同的问题,我找了半天也好像找不到一个适合我自己的解决方法
---------回复--------------
这个跟脚本无关,跟dns有关系.
这是官方的bug介绍
http://bugs.php.net/bug.php?id=11058 |
|