The boss asked me to implement a function of sending emails asynchronously in PHP. I searched for information on the Internet and found that popen can be used, so I initially wrote it like this:
<code>pclose(popen("php -f mymail.php","r"));</code>
This script is an account that uses phpmailer to send an email to me.
Now I want to pass parameters to this function:
$to--recipient
$content--content
$subject--title.
These are essential for the function of sending emails,
but don’t know how to write them?
Are you adding parameters after this command? As follows, == Maybe this is more reliable
<code>php -f mymail.php -a $argv1 -b $argv2</code>
Is there still something that can pass parameters? (But the popen function has 4 parameters that are not the same)
<code>popen("balabala","r",$参数,$参数)</code>
Or should I force it to be written in and then use it directly? It means something like the following
<code>fopen("mymail.php","w"); fwrite $to balabala; fwrite $subject balabala; fclose(fopen(balabala));</code>
I am new to PHP, please forgive me if I have any mistakes, please give me your advice, ==
The boss asked me to implement a function of sending emails asynchronously in PHP. I searched for information on the Internet and found that popen can be used, so I initially wrote it like this:
<code>pclose(popen("php -f mymail.php","r"));</code>
This script is an account that uses phpmailer to send an email to me.
Now I want to pass parameters to this function:
$to--recipient
$content--content
$subject--title.
These are essential for the function of sending emails,
but don’t know how to write them?
Are you adding parameters after this command? As follows, == Maybe this is more reliable
<code>php -f mymail.php -a $argv1 -b $argv2</code>
Is there still something that can pass parameters? (But the popen function has 4 parameters that are not the same)
<code>popen("balabala","r",$参数,$参数)</code>
Or should I force it to be written in and then use it directly? It means something like the following
<code>fopen("mymail.php","w"); fwrite $to balabala; fwrite $subject balabala; fclose(fopen(balabala));</code>
I am new to PHP, please forgive me if I have any mistakes, please give me your advice, ==