Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts

    XAMPP Mail sending on Mac

    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?

  • #2
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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>
    Last edited by Juniper747; 04-10-2012 at 02:51 AM.

  • #3
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,133
    Thanks
    12
    Thanked 332 Times in 328 Posts
    Quote Originally Posted by Juniper747 View Post
    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).
    in this case Id use the SwiftMailer or PHPMailer libraries to reliably send emails (or at least get a decent error message)

    PS. Mac OS X comes with PHP & Apache installed. and there is also the MacPorts system to get you the latest version of PHP/Apache/MySQL/
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    Andr Behrens, NY Times Software Developer

  • Users who have thanked Dormilich for this post:

    Juniper747 (04-11-2012)

  • #4
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    in this case Id use the SwiftMailer or PHPMailer libraries to reliably send emails (or at least get a decent error message)

    PS. Mac OS X comes with PHP & Apache installed. and there is also the MacPorts system to get you the latest version of PHP/Apache/MySQL/
    Not a bad solution... but looks like installing such libraries would require me to change my code temporarily to add certain classes etc. just to send emails.
    But, I do not want to have to change my code... Like I said it worked perfectly at the hospital (likely due to an unsecure ISP), so I need to figure out how to change my computer settings to have the same effect while I'm connected to my home ISP.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I'd suggest that its a simple access configuration in your home router. According to this, it was sent out by my-macbook-pro.local, and that would be consistent with a requirement to configure your own sendmail.
    I'm not sure how it would be done in a mac, but you need to see if its queued up and sent from your machine. PHP cannot determine this (it can determine if the sendmail is valid, but cannot tell if it went anywhere), so you want to see if the actual email is sent and dropped by your host.
    I'd say it could be a simple spam block, but since it works via one network and not the other, this would indicate that the cause is the network itself.
    Needless to say, this hasn't actually a thing to do with PHP itself from the looks of it.

  • Users who have thanked Fou-Lu for this post:

    Juniper747 (04-11-2012)

  • #6
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Thank you... that's great advice, and I agree, seems like it would be a simple security measure by the ISP or router.

    So how would I "see if its queued up and sent from your machine"? I'm pretty sure it was sent by my machine, I mean, where else would it be sent from since localhost is set up on my macbook?

    I can definitely access my verizon fios router, but which configuration would I need to change?

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Check your port configs. Mail typically needs 110 and 25 open for POP3 and SMTP, and 143 for IMAP. SSL versions are 465, 585, 993, 995. I wouldn't be surprised if these are closed.
    As for checking, if the router has a logging feature, see if you can sendmail (even from the command line is sufficient), and check to see if an event is triggered indicating it has blocked or dropped. While I could probably play around with a router long enough to do what I need, I'm not a network specialist so I'm afraid I cannot really advise generically how to fix the issue. You may be able to contact your ISP support as well and let them know you are trying to test sendmail functionality to see if they can walk you through it.

  • #8
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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?

    XAMPP Mail sending on Mac-screen-shot-2012-04-11-12.51.39-pm.png

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

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Have you opened 465 as well?
    Like I said, i can fumble myself through a router config, but I can't really help when it comes to walking someone through. You should contact your ISP to get their support team to help you open any necessary ports. Even once that's done, there is no guarantee that it will allow you to send as it could still be blocked at the ISP level. All this would do is eliminate your home network as the cause.

  • Users who have thanked Fou-Lu for this post:

    Juniper747 (04-11-2012)

  • #10
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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).
    Last edited by Juniper747; 04-11-2012 at 06:53 PM.

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You can set it in php.ini, and restart apache to take effect.
    It can also be provided inline with an ini_set('smtp_port', 582);, or by reconfiguring sendmail as the fourth parameter in the mail() function.

    I'd suggest php.ini is the best to change.

  • Users who have thanked Fou-Lu for this post:

    Juniper747 (04-11-2012)

  • #12
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    You can set it in php.ini, and restart apache to take effect.
    It can also be provided inline with an ini_set('smtp_port', 582);, or by reconfiguring sendmail as the fourth parameter in the mail() function.

    I'd suggest php.ini is the best to change.
    Ok, great... So here's the section in my php.ini:

    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = me@example.com

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    ;sendmail_path =
    So how should I change this?

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Not sure how you would do this in a mac. On Windows you can modify the php.ini and provide the port directly. I don't know if sendmail has a runtime call to let it change its port (I would think so, but the man page I found doesn't indicate that a runtime config exists).
    In linux, you can modify the sendmail.cf file to change the smtp to the port required, which you should copy before attempting. There will be a daemon configuration indicating that SMTP is used; that can be changed to use the port in use.
    On a MAC I'd assume there is probably a gui configuration for this.

  • #14
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Geez.... This looks like it might be more trouble than it's worth!
    I may 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..?

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by Juniper747 View Post
    Geez.... This looks like it might be more trouble than it's worth!
    I may 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..?
    I'd say to not even worry too much about it. You know the mail works. I myself do not allow mail to move through my home machines even from testing, so I develop on the assumption it will work. I test it in a live environment after the fact. I don't actually make explicit calls to the mail function though, I wrap it into an object so I can adjust it from a central location. That way if mail is disabled I could manually send mail through sockets instead, call an IMAP or whatever. All I have to change is the one class that does this lifting and away I go.

  • Users who have thanked Fou-Lu for this post:

    Juniper747 (04-11-2012)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •