I have a script that sends mail in a loop. Unfortunately it is sending only the first.
Mail returns "false" for all sends after the first:
I have a script that sends mail in a loop. Unfortunately it is sending
only the first.
Here is the script segment:
Mail returns "false" for all sends after the first:
error_get_last returns nothing rather than the array expected
I have a script that sends mail in a loop. Unfortunately it is
sending only the first.
Mail returns "false" for all sends after the first:
Here is the script segment:
$to ='william@xxxx.com';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: michigan@xxxxx.org';
// Mail it
$sent =mail($to, $subject, $message, implode("\r\n", $headers));
//debug info
echo "sent:" . var_dump($sent);
echo basename(__FILE__) . ": " . __LINE__ . ": $appNum<br />"; print_r (error_get_last());
echo "<br />";
-------------------------
var_dump ($sent) returns bool(false)
error_get_last returns nothing rather than the array expected
If I put an intentional error above the send error_get_last
correctly reports that.
Does anyone see anything that would generate this or have any
suggestions for debugging the mail send?
here is the debugging output:
-------------------
statusCheckGenerate.php: 160:
to: william@xxxxx.com
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: michigan@xxxxxx.org
bool(true) sent:
statusCheckGenerate.php: 160:
to: william@xxxxxxn.com
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: michigan@xxxxxxx.org
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: michigan@xxxxx.org
bool(false) sent:
I have a script that sends mail in a loop. Unfortunately it is
sending only the first.
Mail returns "false" for all sends after the first:
Here is the script segment:
$to ='william@xxxx.com';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: michigan@xxxxx.org';
here is the debugging output:
-------------------
statusCheckGenerate.php: 160:
to: william@xxxxx.com
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: michigan@xxxxxx.org
bool(true) sent:
statusCheckGenerate.php: 160:
to: william@xxxxxxn.com
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: michigan@xxxxxxx.org
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: michigan@xxxxx.org
bool(false) sent:
bill:
I have a script that sends mail in a loop. Unfortunately it is
sending only the first.
Mail returns "false" for all sends after the first:
Here is the script segment:
$to ='william@xxxx.com';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: michigan@xxxxx.org';
If you do this in a loop you all ADD headers with every loop cycle.
Better do this:
$headers = [
'MIME-Version: 1.0',
'Content-type: text/html; charset=iso-8859-1',
'From: michigan@xxxxx.org',
];
On 13/04/2021 17.22, bill wrote:
I have a script that sends mail in a loop. Unfortunately it is
sending only the first.
Here is the script segment:
As you don't have the whole code, it's just a guess when it comes
to the problem. I would guess it's your headers that grows for
each mail you try to send, also simpler to use an array with
named cells, see php.net documentation.
On 4/13/2021 4:05 PM, J.O. Aho wrote:
On 13/04/2021 17.22, bill wrote:
I have a script that sends mail in a loop. Unfortunately it is
sending only the first.
Here is the script segment:
As you don't have the whole code, it's just a guess when it comes
to the problem. I would guess it's your headers that grows for
each mail you try to send, also simpler to use an array with
named cells, see php.net documentation.
Thank you to J.O Aho and Lew Pitcher and Arno Weizel and Jerry
Stuckle.
I moved the header setting out of the loop and all is good. Many
thanks.
-bill
On 4/14/2021 10:32 AM, Arno Welzel wrote:
bill:
I have a script that sends mail in a loop. Unfortunately it is
sending only the first.
Mail returns "false" for all sends after the first:
Here is the script segment:
$to ='wil...@xxxx.com';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: mich...@xxxxx.org';
If you do this in a loop you all ADD headers with every loop cycle.
Better do this:
$headers = [
'MIME-Version: 1.0',
'Content-type: text/html; charset=iso-8859-1',
'From: mich...@xxxxx.org',
];
Or, since he's not changing the headers, just set $headers once before entering the loop. The same with $subject if that doesn't change.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 349 |
Nodes: | 16 (2 / 14) |
Uptime: | 119:01:08 |
Calls: | 7,612 |
Files: | 12,787 |
Messages: | 5,684,029 |