panique / huge

Simple user-authentication solution, embedded into a small framework.
2.14k stars 788 forks source link

mail sending sometimes does not work due to linux #88

Closed panique closed 11 years ago

panique commented 11 years ago

I just ran some test installations with exactly the same code/config, but different hosters, different linux versions, different versions of PHP etc.. My expectation was to find bugs in the code, but i found something different:

Linux is "not so nice" when sending mails.

The web is full of discussions on this php-sendmail-mail()-issue, and there are masses of possible solutions, and always there's also a big groups of people commenting that this does not work like that.

Anyway, the consequence is: the php mail() function is really bad as it does not return false when mail-sending fails. And as we have no (simple) possibility to guide people how to get sendmail to run, i think using PHPMailer, which overrides the linux mail server, should be implemented as soon as possible. It's an interesting fact that the creators of PHPMailer made sending mails possible with a few lines of code, while PHP itself or in combination with sendmail is not really capable of. Those guys really need a Medal of Honor or something...

TODO: Completely get rid of mail() and sendmail. Implement PHPMailer.

blak3r commented 11 years ago

I think I can shed some light on this... I believe the issue is more of a matter of the ISP your host is on. Lots (if not most) block SMTP on port 25... They're basically trying to prevent a linux box getting compromised and then subsequently becoming an open relay.

I experienced this first hand. My laptop when on my home residential network... sendmail didn't work. When I had it at my office it did. So, in my case this proved that sendmail wasn't necessarily to blame.

I added phpmail and still had a problem UNTIL i changed the SMTP port. Fortunately for me... my SMTP provider (dnsmadeeasy) allowed me to use different ports. Changed to to one of the ones in 5xx and all was good.

So... I suspect sendmail would work if you changed the port (see reference below)... but doing so requires system /etc/ changes which make the script harder to install and less portable. Therefore, It's better to just use phpmailer as it's easier to specify which port to use from code.

I posted the code I used here: https://github.com/panique/php-login/issues/59

Here's a reference: http://helpdocs.westserver.net/v3/sitemanager/Sendmail_Alternate.htm

Some ISPs Known to Block Port 25

Below is a list of some of the major ISPs that are known to block port 25. While this list is a good starting point, it is far from complete and is prone to change over time. Ultimately, the most reliable way of knowing whether your ISP is blocking port 25 is to contact them directly and ask. You can also use the How to Check if your ISP blocks SMTP guide found at the bottom of this page.

ISP SMTP Server
AOL smtp.mail.aol.com
Adelphia    mail.adelphia.net
Ameritech   mailhost.det.ameritech.net
AT&T    mailhost.att.net
AT&T Global smtp1.attglobal.net
Bell Internet High Speed (Canada)   smtp10.bellnet.ca
Bell south  mail.bellsouth.net
CableOne    mail.cableone.net
Charter Communications  smtp.chartermi.net
Charter.net smtp.charter.net
CharterTN.net   mail.chartertn.net
CharterMI.net   mail.chartermi.net
Cinncinnati Bell/Fuse Dial-up   smtp.fuse.net
Coax.net    smtp.west.coax.net /east / central
Comcast smtp.comcast.net
Cox smtp.west.cox.net; smtp.central.cox.net; smtp.east.cox.net (either of the three depending on your location).
Earthlink   smtp.earthlink.net
Etisalat    smtp.emirates.net.ae
Epix    out.epix.net
Erols   smtp.erols.com
Frontiernet.net smtp.frontiernet.net
Fuse    smtp.fuse.net
Juno    smtp.juno.com
Mindspring  smtp.mindspring.com
MSN smtp.email.msn.com
MSN.DSL secure.smtp.email.msn.com
NEBI.com    mail.nebi.com
Netcom  smtp.ix.netcom.com
NetZero smtp.netzero.net
OOL (Optimum Online)    mail.optonline.net
Pacific Bell (Pacbell)  mail.pacbell.net
Panix.com   mailhost.panix.com
PeoplePC    smtp.peoplepc.com
Quixnet.net smtp.quixnet.net
RCN smtp.rcn.com
Road Runner (NYC)   smtp-server.nyc.rr.com (if outside the NYC area, please call your local Road Runner Support team)
Rogers Hi-Speed smtp.broadband.rogers.com
SBC smtp.sbcglobal.net
SBC Yahoo   smtp.sbcglobal.yahoo.com
Speakeasy   mail.speakeasy.net
The-Beach.net   mail.the-beach.net
Verio   smtp.veriomail.com
Verizon outgoing.verizon.net or smtpout.verizon.net
How to Check if your ISP blocks SMTP

Windows Users

Click Start from your Windows Taskbar.
Click Run... from the Windows Start menu.
Type telnet smtp1.arin.net 25 into the Run... dialogue box.
Press Enter or Return.
Mac Users

Launch Terminal.
At the $ sign prompt, type telnet smtp1.arin.net 25.
Press Enter or Return.
Linux Users

At the command line prompt, type telnet smtp1.arin.net 25
Press Enter or Return.
if you get back 220 smtp1.arin.net . . . your ISP DOES NOT block port 25.

If your connection hangs, fails, or returns something other than smtp1.arin.net then your ISP IS blocking or redirecting port 25 to their own server.
panique commented 11 years ago

Thanks! ;) I just realized PHPMailer needs an (external?) SMTP account. Pfft... I think it gets complicated now... Users of the script would have to create an account somewhere. That's very annoying in my eyes. The entire email process of their applications would then go over that external provider. That's not really simple...

panique commented 11 years ago

I would really appreciate "bulletproof" out-of-the-box email sending.

blak3r commented 11 years ago

Maybe add sendgrid support then. I don't think that having an smtp server is that big a deal.

All ISPs have them for their users. Just has to be configured.

~blake

On Jun 15, 2013, at 2:12 PM, panique notifications@github.com wrote:

I would really appreciate "bulletproof" out-of-the-box email sending.

— Reply to this email directly or view it on GitHub.

panique commented 11 years ago

You are totally right! I'm totally stuck with naked root servers, I totally forgot that most people simply rent packages with domains, mail accounts, server etc. ... But how would people handle this who rent naked servers ? Maybe the sendmail mail() thing should stay in the script, optionally.

UpD commented 11 years ago

http://stackoverflow.com/questions/43970/configuring-sendmail-behind-a-firewall

GrahamCampbell commented 11 years ago

Is this not a duplicate issue of #59 ?

panique commented 11 years ago

This is something that is out of the limits of this script, i think a proper tutorial or the currently released SMTP possibility will be acceptable solutions.