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 ='[email protected]';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: [email protected]';
// 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: [email protected]
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: [email protected]
bool(true) sent:
statusCheckGenerate.php: 160:
to: [email protected]
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: [email protected]
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: [email protected]
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 ='[email protected]';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: [email protected]';
here is the debugging output:
-------------------
statusCheckGenerate.php: 160:
to: [email protected]
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: [email protected]
bool(true) sent:
statusCheckGenerate.php: 160:
to: [email protected]
headers: MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: [email protected]
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: [email protected]
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 ='[email protected]';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: [email protected]';
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: [email protected]',
];
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 ='[email protected]';
$subject ='IRWOM Status Update request';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: [email protected]';
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: [email protected]',
];
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
[email protected]
==================
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 149:20:55 |
| Calls: | 12,091 |
| Calls today: | 4 |
| Files: | 15,000 |
| Messages: | 6,517,572 |