So something interesting I encountered while working on my site. I use Xampp on a mac OXS Lion to run my website. And I have mail() functions in my code that never worked (sent outgoing mail) before while I was connected to my home internet connection (Verizon Fios).

However, I was recently at a local hospital and logged onto the internet through what seemed to be an unsecure internet connection. While I was working on my site, all of a sudden the mail() functions started working and sending mail... But, when i got back home, it did not work anymore!

How can I figure out what was different, so that I can change some settings maybe in php.ini or maybe my computer configuration, so that I can get it to send mail, like it was doing at the hospital. I am trying to figure it out... any ideas?

    FYI

    Here is the mail header from the email sent to my gmail account:

    I x-ed out my ip address... and y-ed out the "received by".

    Delivered-To: myemail@gmail.com
    Received: by yy.yy.yyy.yyy with SMTP id wx8csp106470vdb;
    Fri, 6 Apr 2012 10:59:28 -0700 (PDT)
    Received: by 10.224.116.6 with SMTP id k6mr10527899qaq.91.1333735167849;
    Fri, 06 Apr 2012 10:59:27 -0700 (PDT)
    Return-Path: <nobody@my-macbook-pro.local>
    Received: from my-MacBook-Pro.local ([xxx.xxx.x.xx])
    by mx.google.com with ESMTP id es10si7285733qab.33.2012.04.06.10.59.27;
    Fri, 06 Apr 2012 10:59:27 -0700 (PDT)
    Received-SPF: neutral (google.com: xxx.xxx.x.xx is neither permitted nor denied by best guess record for domain of nobody@my-macbook-pro.local) client-ip=xxx.xxx.x.xx;
    Authentication-Results: mx.google.com; spf=neutral (google.com: xxx.xxx.x.xx is neither permitted nor denied by best guess record for domain of nobody@my-macbook-pro.local) smtp.mail=nobody@my-macbook-pro.local
    Received: by my-MacBook-Pro.local (Postfix, from userid 4294967294)
    id 8FF04156E2F; Fri, 6 Apr 2012 13:59:27 -0400 (EDT)
    To: myemail@gmail.com
    Subject: You Requested a New Password
    From: admin@mysite.com
    MIME-Version: 1.0
    Content-type: text/html; charset=iso-8859-1
    Message-Id: <20120406175927.8FF04156E2F@my-MacBook-Pro.local>
    Date: Fri, 6 Apr 2012 13:59:27 -0400 (EDT)

    <div>
    This is the email notification to reset your email address!
    </div>

      It's most likely that your home ISP is not passing the mail on sent from your system. You could send the mail via SMTP (presumably your ISP offers this, or use the SMTP details from one of your email accounts)

      To test that email is working as intended you could send it to the local account. On Linux systems this is root@localhost, presumably it would work for a Mac too? You can then check your email with the mail command in whatever command line app a Mac uses.

        Ashley Sheridan;11001411 wrote:

        It's most likely that your home ISP is not passing the mail on sent from your system. You could send the mail via SMTP (presumably your ISP offers this, or use the SMTP details from one of your email accounts)

        To test that email is working as intended you could send it to the local account. On Linux systems this is root@localhost, presumably it would work for a Mac too? You can then check your email with the mail command in whatever command line app a Mac uses.

        So I went into my router and created a new port forwarding rule using the ip address of localhost and giving it the port 25 (which is the default defined in the php.ini file for my localhost server). Here's a screen shot:

        [ATTACH]4504[/ATTACH]

        After testing email, it still does not work...?

          juniper747;11001432 wrote:

          So I went into my router and created a new port forwarding rule using the ip address of localhost

          ... so the server you want to forward that port to is running on the router itself? (That's what you're saying by using 'localhost' as the destination.)

          EDIT: Also note that the port forwarding is only going to matter for incoming requests received by your router on port 25. Aren't you trying to get outgoing connections (e.g. from your computer) to work?

          As Ashely points out above, it's likely that your ISP is blocking outgoing connections on port 25 other than to their own SMTP servers (this isn't an uncommon practice among ISPs these days). As such, there's nothing on your end that you can do to change this; either try using port 587 for the connection to the external SMTP server, or contact your ISP to figure out if they're blocking outgoing port 25 connections and, if so, whether they provide an opt-out option you could pursue.

            Ok, thanks for the tips...
            So I just got off the phone with my ISP and they said that they allow emails through the following ports:

            For SSL:
            POP 995
            SMTP 465

            For non-SSL
            POP 110
            SMTP 587

            So... I'm pretty sure localhost php uses smtp, and I do not think that the emails are getting stopped at the router but rather at the ISP server. So my question is, where/how do I change the port to either 465 or 582? Is it in my php.ini file? (note that I'm running on a Mac).

              juniper747;11001438 wrote:

              where/how do I change the port to either 465 or 582? Is it in my php.ini file? (note that I'm running on a Mac).

              The non-SSL port for SMTP should be 587, not 582.

              Otherwise, since you're not on Windows you'll have to adjust your MTA (Message Transfer Agent) to connect to external SMTP servers using port 587 rather than 25. How to do this should be explained in the documentation for whichever MTA (such as sendmail) you're using.

                The alternative is to use something like PearMail to send the email. It's a class which you use instead of PHPs native mail() calls, and makes it very easy to set up SMTP connections with various different settings.

                  Thanks, but I decided that all this may be more trouble than it's worth! I already know the email works. So I think I'll be better off just going back to that hospital with the insecure Internet connection to test out my mailing functions! Especially since I am just testing my site on my local computer... Then, once I'm ready to go live with my site and move it to a real server like rackspace, I assume their techs would help me set everything up as far as emailing etc..

                    Write a Reply...