我希望对另一台服务器上的另一个脚本发出一个简单的GET请求.我该怎么做呢?
在一种情况下,我只需要请求外部脚本而无需任何输出.
make_request('http://www.externalsite.com/script1.php?variable=45'); //example usage
Run Code Online (Sandbox Code Playgroud)
在第二种情况下,我需要获取文本输出.
$output = make_request('http://www.externalsite.com/script2.php?variable=45');
echo $output; //string output
Run Code Online (Sandbox Code Playgroud)
说实话,我不想乱用CURL,因为这不是CURL的工作.我也不想使用http_get,因为我没有PECL扩展.
fsockopen会工作吗?如果是这样,如何在不读取文件内容的情况下执行此操作?没有其他办法吗?
谢谢大家
我应该补充一下,在第一种情况下,我不想等待脚本返回任何内容.据我所知,file_get_contents()会等待页面完全加载等?
我正在使用PHPMailer发送效果很好的电子邮件.但问题是,由于它同步发送电子邮件,后续页面加载需要很长时间.
我正在使用PhpMailer,如本例所示https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
我想知道是否有办法使电子邮件传递异步.我对此进行了研究,发现sendmail可以选择将DeliveryMode设置为"后台模式" - 来源http://php.net/manual/en/function.mail.php
mail($to, $subject, $message, $headers, 'O DeliveryMode=b');
Run Code Online (Sandbox Code Playgroud)
我想知道在PhpMailer中是否可以做类似的事情?有人有这个成功吗?
编辑: - (附加信息)好像PhpMailer可以配置为使用sendmail - https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php 因此我想知道这是否可以某种方式利用启用背景交付.
/**
* Which method to use to send mail.
* Options: "mail", "sendmail", or "smtp".
* @type string
*/
public $Mailer = 'mail';
/**
* The path to the sendmail program.
* @type string
*/
public $Sendmail = '/usr/sbin/sendmail';
/**
* Whether mail() uses a fully sendmail-compatible MTA.
* One which supports sendmail's "-oi -f" options.
* @type boolean …
Run Code Online (Sandbox Code Playgroud)