Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18609

Re: problem figuring out why mail fails

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.php
Subject Re: problem figuring out why mail fails
Date Wed, 14 Apr 2021 16:32:40 +0200
Lines 63
Message-ID <idoco8FjgsfU1@mid.individual.net> (permalink)
References <s54d0b$spc$1@gioia.aioe.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace individual.net kE2DnonVNdmQwm7mDxD6QwDlzYlPcpXZCvHvZ3QfJYWRFz9FyM
Cancel-Lock sha1:H6q0KRFbMzpVnATKRcrb8PBYlfk=
In-Reply-To <s54d0b$spc$1@gioia.aioe.org>
Xref csiph.com comp.lang.php:18609

Show key headers only | View raw


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',
];

[...]
> 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:

Don't you see that the second mail has every header twice?

This is because of the reason I explained above.

Don't get me wrong - but at this experience level you should not create
scripts which send e-mails at all. By sending a lot of e-mails this way
your provider or hoster will soon be blocked because of outgoing spam
from his network. You also need to check how many e-mails per hour are
acceptable for your hoster/provider and you also need to add certain
headers to indicate that the e-mails are either transactional or
originate from a subscriber list.

Maybe using a service like Mailjet, Sendinblue, smtp2go etc. and the
respective API of these services is the better choice for you.

-- 
Arno Welzel
https://arnowelzel.de

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

problem figuring out why mail fails bill <william@TechServSys.com> - 2021-04-13 11:22 -0400
  Re: problem figuring out why mail fails Jeroen Belleman <jeroen@nospam.please> - 2021-04-13 21:01 +0200
  Re: problem figuring out why mail fails "J.O. Aho" <user@example.net> - 2021-04-13 22:05 +0200
    Re: problem figuring out why mail fails bill <william@TechServSys.com> - 2021-04-16 08:33 -0400
      Re: problem figuring out why mail fails Kristall <kristallin555@gmail.com> - 2023-02-27 02:40 -0800
  Re: problem figuring out why mail fails Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-04-13 21:08 +0000
  Re: problem figuring out why mail fails Arno Welzel <usenet@arnowelzel.de> - 2021-04-14 16:32 +0200
    Re: problem figuring out why mail fails Jerry Stuckle <jstucklex@attglobal.net> - 2021-04-14 12:58 -0400
      Re: problem figuring out why mail fails Kristall <kristallin555@gmail.com> - 2023-02-27 02:40 -0800

csiph-web