Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-10-2012, 02:35 AM   PM User | #1
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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?
Juniper747 is offline   Reply With Quote
Old 04-10-2012, 02:49 AM   PM User | #2
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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..
Juniper747 is offline   Reply With Quote
Old 04-10-2012, 07:12 AM   PM User | #3
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,857
Thanks: 9
Thanked 288 Times in 284 Posts
Dormilich is on a distinguished road
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 I’d 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/…
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Users who have thanked Dormilich for this post:
Juniper747 (04-11-2012)
Old 04-10-2012, 05:10 PM   PM User | #4
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
Quote:
Originally Posted by Dormilich View Post
in this case I’d 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.
Juniper747 is offline   Reply With Quote
Old 04-10-2012, 08:27 PM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Juniper747 (04-11-2012)
Old 04-11-2012, 02:30 AM   PM User | #6
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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?
Juniper747 is offline   Reply With Quote
Old 04-11-2012, 06:08 AM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Old 04-11-2012, 05:55 PM   PM User | #8
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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?

Click image for larger version

Name:	Screen Shot 2012-04-11 at 12.51.39 PM.png
Views:	20
Size:	14.1 KB
ID:	11036

After testing email, it still does not work...
Juniper747 is offline   Reply With Quote
Old 04-11-2012, 06:06 PM   PM User | #9
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Juniper747 (04-11-2012)
Old 04-11-2012, 06:47 PM   PM User | #10
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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..
Juniper747 is offline   Reply With Quote
Old 04-11-2012, 06:56 PM   PM User | #11
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Juniper747 (04-11-2012)
Old 04-11-2012, 07:29 PM   PM User | #12
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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:

Quote:
[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?
Juniper747 is offline   Reply With Quote
Old 04-11-2012, 07:44 PM   PM User | #13
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Old 04-11-2012, 08:17 PM   PM User | #14
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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..?
Juniper747 is offline   Reply With Quote
Old 04-11-2012, 09:36 PM   PM User | #15
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Juniper747 (04-11-2012)
Reply

Bookmarks

Tags
mac, mail, mail(), xampp

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:02 AM.


Advertisement
Log in to turn off these ads.