I want to send an email with automatted content from a login script, but it should be sent with a delay of some (randomized) seconds (for sending one part of a key pair).
Thats why I was trying to use curl, which generally works, instead of using "include" or a class, but the main script should not have to wait until sleep() is ended.
main code is (simple curl code) playing around with "CURLOPT_MUTE,1" and "CURLOPT_RETURNTRANSFER,false" did not work at all.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://domain/path/to/delayed_mail.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
'to=' . $to . '&from=' . $from . '&subject=...');
curl_exec ($ch);
curl_close ($ch);
?>
delayed_mail.php looks something like this
<?php
//path to mail class
//some POST and GET REQUEST filters and authentications
//with $_REQ[$key]=$value; as output
$delay = rand(2,32);
sleep($delay);
$ddlab->mail->html($_REQ['to'],$_REQ['from'],...,$_REQ['options']);
?>
As I mentioned above, I got stuck a bit. The main script which is for html output, shall not wait, until email is sent, after sleep().
1st question: How "delayed_mail.php" can be executed independent (Send email whenever you want to do so, but leave my script running!)
2nd question: How can I set an internal path like '../../delayed_mail.php' or getcwd().'/delayed_mail.php' (which both doesn´t seem to work) instead of full "http://"-URL ?
Thanks for your efforts.