Discussion:
mail() problems
Jim Giner
2014-09-04 13:13:29 UTC
Permalink
I've been using the built-in (?) 'mail()' function quite successfully so
far (ie, a couple of years) and have not had need to seek an alternate.
That said, I now have to ask the group if there are known cases of
intermittent success with this tool.

I have a pretty good working template for handling emails with a piped
script that sends it results to a std mailbox for review after the
script does it thing. I have several (3-4) scripts linked to mailboxes
that work successfully every time, meaning that my db gets updated and
the emails get sent. Recently I built a new mailbox, made a new script
from my template and began testing. At first (after clearing out all
the syntax errors) it worked successfully but then after a dozen or so
tests I stopped getting the emails. Now it gets weird.

Sometimes the script doesn't seem to run at all since my db doesn't get
updated nor do I receive an email. Other times the db does get updated
but I still get no email. I have debugged and debugged and placed
incremental 'send email' steps throughout my code and still no emails
come back.

But then all of a sudden it works! My hosting co. says there is no
problem with my email accounts and no errors showing, nor do I have any
error logs that show anything. It's been about 4 days now and I am at a
loss to explain it.

Could it be possible that php or mail() is truly buggy and tempermental?

FYI -my host is running mysql 5.5.37(cli) with php 5.4.31 on apache 2.2.7
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
John
2014-09-04 13:20:51 UTC
Permalink
Post by Jim Giner
Could it be possible that php or mail() is truly buggy and tempermental?
I never liked the build in mail() since external SMTP servers had to be
configured in php.ini. I ended up writing a replacement class that will
talk to "any" external SMTP server directly using sockets. I have used
this on numerous hosting accounts and for me "it just works", even on
Windows (XAMPP).

I know this is not an answer to your question but your method sounds
very complicated and my script may make things easier :)

http://www.kaisersoft.net/t.php?phpemail

Sincerely,
--
Mirko
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-09-04 13:36:50 UTC
Permalink
Thanks for responding John, but I don't know why you think my method
sounds complicated since I didn't describe 'my method' in detail. I
simply said that mail() isn't working consistently in my script - one
single script - which is from a template of a working process that has
previously worked without problems.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Aziz Saleh
2014-09-04 14:41:47 UTC
Permalink
Post by Jim Giner
Thanks for responding John, but I don't know why you think my method
sounds complicated since I didn't describe 'my method' in detail. I simply
said that mail() isn't working consistently in my script - one single
script - which is from a template of a working process that has previously
worked without problems.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Have you tried debugging via file writing (as opposed to incrementally
sending yourself an email)?: file_put_contents('/home/debug.txt',
$debugCode, FILE_APPEND);
Jim Giner
2014-09-04 15:32:55 UTC
Permalink
Post by Aziz Saleh
Have you tried debugging via file writing (as opposed to incrementally
sending yourself an email)?: file_put_contents('/home/debug.txt',
$debugCode, FILE_APPEND);
Can't write a file - must be a permissions thing. BUT I can write to
the php 'error_log' file and do get messages that indicate to me that
everything is happening as it should. I just don't receive the email

The really weird thing is that a syntax error forces the email to arrive
followed by a 'delivery failure' message because of the error trying to
send output.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Paul M Foster
2014-09-04 19:38:39 UTC
Permalink
Post by Jim Giner
I've been using the built-in (?) 'mail()' function quite
successfully so far (ie, a couple of years) and have not had need to
seek an alternate. That said, I now have to ask the group if there
are known cases of intermittent success with this tool.
I have a pretty good working template for handling emails with a
piped script that sends it results to a std mailbox for review after
the script does it thing. I have several (3-4) scripts linked to
mailboxes that work successfully every time, meaning that my db gets
updated and the emails get sent. Recently I built a new mailbox,
made a new script from my template and began testing. At first
(after clearing out all the syntax errors) it worked successfully
but then after a dozen or so tests I stopped getting the emails.
Now it gets weird.
Sometimes the script doesn't seem to run at all since my db doesn't
get updated nor do I receive an email. Other times the db does get
updated but I still get no email. I have debugged and debugged and
placed incremental 'send email' steps throughout my code and still
no emails come back.
But then all of a sudden it works! My hosting co. says there is no
problem with my email accounts and no errors showing, nor do I have
any error logs that show anything. It's been about 4 days now and I
am at a loss to explain it.
Could it be possible that php or mail() is truly buggy and tempermental?
FYI -my host is running mysql 5.5.37(cli) with php 5.4.31 on apache 2.2.7
For what it's worth, I never ever trust what a hosting vendor says about
his environment and the state of his network. If your code always worked
and then it doesn't, it virtually has to be your hosting company.

I also don't know how many times I've had to contact hosting companies
because it's become clear to me that their email servers have gotten
wedged. Or they'll change something on their network and never tell
anyone.

Here's a ridiculous (but real) example: I had been hosting for years
with this hosting company (Company X). I'd had increasing problems with
their mailing hosts, as I used them for sending and receiving email for
my company. Investigation turned up the following: When I had signed on
with them years ago, they had recommended ns1.companyx.net and
ns2.companyx.net for nameservers at my registrars. When they found out
that my registrars were still using these nameservers, I was informed that
ns1.companyx.net was kinda working and ns2.companyx.net was defunct, and
I really should be using ns23.companyx.net and ns24.companyx.net. Those
were their "modern" nameservers.

Immediately a couple of questions occurred to me. First, what
self-respecting hosting company allows old nameservers to simply age out
and die without telling all their clients who would be relying on those
nameservers? Second, who would simply move to different nameservers
without upgrading the old ones so that clients didn't have to go back to
their registrars and change nameservers?

They also asked me, in light of my email problems, if I wouldn't prefer
using IMAP instead of POP3 for my email? And I'm thinking, "Are you
freaking kidding me? What does that have to do with ANYTHING? If I
wanted IMAP, I'd already be doing it, pinheads". All that question does
is tell me definitively, 1) you don't really have a clue what's wrong,
and 2) you don't want to fix whatever it is.

And don't think this is just some guy in his living room. These guys are
a major hosting company whose name you'd probably recognize if you've
shopped for hosting in the last decade.

Needless to say, I moved all my internal (company) sites off of these
guys after this.

Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Jagielski
2014-09-04 19:42:59 UTC
Permalink
What's wrong w PHPMailer?
Post by Paul M Foster
Post by Jim Giner
I've been using the built-in (?) 'mail()' function quite
successfully so far (ie, a couple of years) and have not had need to
seek an alternate. That said, I now have to ask the group if there
are known cases of intermittent success with this tool.
I have a pretty good working template for handling emails with a
piped script that sends it results to a std mailbox for review after
the script does it thing. I have several (3-4) scripts linked to
mailboxes that work successfully every time, meaning that my db gets
updated and the emails get sent. Recently I built a new mailbox,
made a new script from my template and began testing. At first
(after clearing out all the syntax errors) it worked successfully
but then after a dozen or so tests I stopped getting the emails.
Now it gets weird.
Sometimes the script doesn't seem to run at all since my db doesn't
get updated nor do I receive an email. Other times the db does get
updated but I still get no email. I have debugged and debugged and
placed incremental 'send email' steps throughout my code and still
no emails come back.
But then all of a sudden it works! My hosting co. says there is no
problem with my email accounts and no errors showing, nor do I have
any error logs that show anything. It's been about 4 days now and I
am at a loss to explain it.
Could it be possible that php or mail() is truly buggy and tempermental?
FYI -my host is running mysql 5.5.37(cli) with php 5.4.31 on apache 2.2.7
For what it's worth, I never ever trust what a hosting vendor says about
his environment and the state of his network. If your code always worked
and then it doesn't, it virtually has to be your hosting company.
I also don't know how many times I've had to contact hosting companies
because it's become clear to me that their email servers have gotten
wedged. Or they'll change something on their network and never tell
anyone.
Here's a ridiculous (but real) example: I had been hosting for years
with this hosting company (Company X). I'd had increasing problems with
their mailing hosts, as I used them for sending and receiving email for
my company. Investigation turned up the following: When I had signed on
with them years ago, they had recommended ns1.companyx.net and
ns2.companyx.net for nameservers at my registrars. When they found out
that my registrars were still using these nameservers, I was informed that
ns1.companyx.net was kinda working and ns2.companyx.net was defunct, and
I really should be using ns23.companyx.net and ns24.companyx.net. Those
were their "modern" nameservers.
Immediately a couple of questions occurred to me. First, what
self-respecting hosting company allows old nameservers to simply age out
and die without telling all their clients who would be relying on those
nameservers? Second, who would simply move to different nameservers
without upgrading the old ones so that clients didn't have to go back to
their registrars and change nameservers?
They also asked me, in light of my email problems, if I wouldn't prefer
using IMAP instead of POP3 for my email? And I'm thinking, "Are you
freaking kidding me? What does that have to do with ANYTHING? If I
wanted IMAP, I'd already be doing it, pinheads". All that question does
is tell me definitively, 1) you don't really have a clue what's wrong,
and 2) you don't want to fix whatever it is.
And don't think this is just some guy in his living room. These guys are
a major hosting company whose name you'd probably recognize if you've
shopped for hosting in the last decade.
Needless to say, I moved all my internal (company) sites off of these
guys after this.
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
===========================================================================
Jim Jagielski [|] ***@jaguNET.com [|] http://www.jaguNET.com/
"Great is the guilt of an unnecessary war" ~ John Adams
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-09-04 19:47:00 UTC
Permalink
I can sympathize with your problem, especially since yours was much more
important than mine.

So far today I've had mail and I've not had mail. My hoster even tested
my script by generating an email which generated an error email message
to me. Eureka! I thought it was solved somehow, but they said they
didn't do anything. Anyway for the next hour I was getting responses
and testing away until suddenly I stopped receiving those emails. At
this point they say it's my script. I say it's their email server. I
even took a couple hours off and when I got back there was an email
message waiting for me that was over 2 hours old. Forwarded it to them
to see if they could see something wrong with it but they insisted they
needed to see my script. Guess I'll have to punt this one.

Funny tho - my older email scripts are still working just fine - using
the same basic code, especially the emailing function. Same server,
same address for the mail, just different inboxes that are attached to
each script.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Andrew Ballard
2014-09-04 21:27:42 UTC
Permalink
Post by Jim Giner
So far today I've had mail and I've not had mail. My hoster even tested
my script by generating an email which generated an error email message to
me. Eureka! I thought it was solved somehow, but they said they didn't do
anything. Anyway for the next hour I was getting responses and testing
away until suddenly I stopped receiving those emails. At this point they
say it's my script. I say it's their email server. I even took a couple
hours off and when I got back there was an email message waiting for me
that was over 2 hours old. Forwarded it to them to see if they could see
something wrong with it but they insisted they needed to see my script.
Guess I'll have to punt this one.
Funny tho - my older email scripts are still working just fine - using the
same basic code, especially the emailing function. Same server, same
address for the mail, just different inboxes that are attached to each
script.
How much mail is your script generating? Is there a chance that you've
exceeded your host's allowed message rate? I had frustration years ago with
a site that tried sending a newsletter to its members. After they reached a
certain size, the number of members exceeded the host's limit on how many
messages could be sent in an hour. I got no error messages or any
indication that something went wrong. It just stopped sending messages
after it reached the limit and quietly discarded the rest. Troubleshooting
was really difficult because I never knew how many people received the
message and how many didn't.

Andrew
Robert Williams
2014-09-05 00:24:39 UTC
Permalink
Jim,

I’m not an e-mail expert, but there’s nothing inherently wrong with the mail() function. Basically, all it does is hand off the message to whatever mail server is specified in the php.ini file. In most cases, at least on *nix servers, that means dropping it into the local sendmail queue. If it meets your needs, keep using it. If that’s the case, it’s better than using an overly complicated wrapper that will probably end up just using the mail() function, anyway. We routinely send thousands of messages a day using mail() without any problems whatsoever, running under PHP versions ranging from 5.1.4 to the latest 5.5.

There are a few things that can cause mail to periodically fail, however:

* Some mail servers really want a from: and/or reply-to: header, neither of which is usually set by mail() by default.

* Anti-spam software or hardware somewhere in the chain might also reject messages for various reasons, such as DNS records not being set up right.

* If the local mail server is set to relay through a list of other servers (e.g., for load balancing), one of the servers may be failing — a misconfigured firewall is blocking it, authentication is failing, whatever, hardware is dying, whatever.

* The mail server may be configured to avoid outgoing spam by rate-limiting you to a certain number of messages/hour, messages/day, messages/domain, messages at once, and so on.

* The receiving mail server may be using gray listing, and the sending mail server isn’t handling it properly.

* Some message content, such as certain strings of HTML and certain types attachments (or even attachment names), may cause the message to be blocked by anti-virus hardware/software somewhere along the way.

* Finally, make sure there’s not an error in your code. For example, maybe you’re trying to use a null object in some cases, or something else odd like that. Make sure error_reporting is cranked up and error_log is recording any notices/warnings/errors someplace where you can review them.

As a first step, make sure you’re checking the result of the mail() call. It’ll return a boolean to let you know whether it successfully handed off the message to the mail server. That doesn't mean it’ll get delivered, but at least you know the first handoff worked.

The next step is to check the mail server log, often /var/log/maillog. There, you can see information about how the local mail server is handing off to the receiving server (or to the relay server, if applicable). I’m spoiled in that I have full access to all of our application servers, but if you’re on a shared host, you’ll probably need the host’s help with this. (And note, if your code or your host’s mail servers are somehow at fault, switching away from mail() isn’t likely to help you.)

<small self-promotion>
It so happens that the company I work for offers a variety of hosting services, backed by a 24/7/365 US-based e-mail/chat/phone support team. If you are interested in learning more, let me know and I will have someone contact you. ‘Nuff said on that.
</small self-promotion>

Good luck!


Regards,
Bob

--
Robert E. Williams, Jr.
Senior Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/

Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any).
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Lester Caine
2014-09-04 19:47:49 UTC
Permalink
Post by Paul M Foster
And don't think this is just some guy in his living room. These guys are
a major hosting company whose name you'd probably recognize if you've
shopped for hosting in the last decade.
Needless to say, I moved all my internal (company) sites off of these
guys after this.
Sounds very familiar. Helped a new customer out who had got nothing out
of his hosting company after three days of all his sites being down.
They finally contacted him several days after we got Nominet to change
the tags to ask if there was a problem! And then they tried to charge
for some renewals :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...