/    Sign up×
Community /Pin to ProfileBookmark

PHPMailer Inconsistant

My issue is: It appears not all emails are being sent. Can PHP overlook or skip past “included” code some code if the page loads too quickly??

Sound crazy? Here’s why I ask.

I’ve got a page where I’m processing a form post. Saving the data into a database but also emailing a copy to the person.

I’m using PHPMailer

On my form process page I have my SQL code then have this line to the page where the email is created and sent.

`require ‘mailer/sendEmail.php’;`

I have the row ID of the data I’ve saved from my form by using

`mysqli_insert_id();`

And on my sendEmail.php page I query this and get the data again. When I call sendEmail.php and pass in a ID the email send’s 100% of the time.

Also, even when emails aren’t sent. The data is saved in my database.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@act78723Aug 11.2020 — Without seeing your form process page and sendEmail.php we really can't help you. Please post them enclosing them with the </> bb code.
Copy linkTweet thisAlerts:
@VITSUSAAug 12.2020 — @kiwis80#1622011 I agree with Act78723. Without review your form process page and sendEmail.php how can i help you?
Copy linkTweet thisAlerts:
@NachfolgerAug 12.2020 — > @kiwis80#1622011 Can PHP overlook or skip past "included" code some code if the page loads too quickly?

No. No it cannot. Post the relevant code.
Copy linkTweet thisAlerts:
@NogDogAug 12.2020 — It won't arbitrarily "skip past" any code, but there can be other reasons code does not get processed, such as a fatal error in the preceding code causing any further processing to occur, or things being in if/else blocks that are not triggered for some reason, etc. There is no way we can just magically guess which of those or other possible cases may be happening without access to error logs and/or source code. Does your call to phpMailer's send/execute/whatever function check to see if it succeeds, and return and/or log an error if it does not?
Copy linkTweet thisAlerts:
@act78723Aug 12.2020 — @kiwis80#1622011 We also need to see your email validation code.
Copy linkTweet thisAlerts:
@kiwisauthorAug 12.2020 — @NogDog#1622051

On the error issue.

Is there a way to turn on global errors within PHP and log them?

Currently some errors are giving my site HTTP ERROR 500 and nothing is being logged.
Copy linkTweet thisAlerts:
@NogDogAug 12.2020 — You can set things in the php.ini file if you have access, or in a local .htaccess file if on Apache (may have to search for the applicable syntax for that). All the various error-related settings are listed/described at https://www.php.net/manual/en/errorfunc.configuration.php . Probably display_errors and error_reporting are the main things of interest.

Also, a quick way to look for syntax errors on any given file is to "lint" it locally via the command line (if your editor doesn't do that for you?):
<i>
</i>php -l /path/to/file.php

(That's a lower-case "L" for the -l option.)
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...