繁体   English   中英

在远程服务器上获取404,但可以在本地服务器上打开页面

[英]Get 404 on remote server but can open page on local server

我的以下代码有问题。 应该将电子邮件发送到电子邮件服务器提供商。 它在本地服务器上可以正常工作,但是当我在远程服务器上对其进行测试时,总是得到:

404 Page Not Found
The page you requested was not found.

对于为什么发生这种情况的任何想法都将受到高度赞赏。

码:

 public function index ()
 {   
    $recipient = $email;
    $title = 'You've got mail';
    $body = 'I love you!';

    $data=
    array(
    'api_user'=>'postmaster@sendcloud.org',
    'api_key' =>'password',
    'from'=>'raphael.luo@live.com',
    'to'=>$recipient,
    'subject'=>$title,
    'html'=>$body
    );

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_URL, 'https://sendcloud.sohu.com/webapi/mail.send.json');

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);       

     $result = curl_exec($ch); 

     curl_close($ch);

    print_r($result);

}

这可能是安全通讯的问题(您的网址为https:// )。 因此,如果使用不安全的通信没有任何问题,请在代码中添加curl选项,然后重试:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);

同样,将http_build_query函数用于POST数据始终是安全的。

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM