Solved

PHP - fsocket connections failing (time out), not sure why...

Posted on 2014-02-20
3
1,232 Views
Last Modified: 2014-02-27
Hi,

I am attempting to deliver emails directly by connecting to my recipients smtp server.

However when the script tries to connect to googles mail servers it times out. Can anyone see why?

Warning: fsockopen() [function.fsockopen]: unable to connect to alt2.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to alt3.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to alt4.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to alt1.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Open in new window


array(2) { ["mx"]=> array(5) { [0]=> string(23) "alt2.aspmx.l.google.com" [1]=> string(23) "alt3.aspmx.l.google.com" [2]=> string(23) "alt4.aspmx.l.google.com" [3]=> string(18) "aspmx.l.google.com" [4]=> string(23) "alt1.aspmx.l.google.com" } ["weight"]=> array(5) { [0]=> int(30) [1]=> int(40) [2]=> int(50) [3]=> int(10) [4]=> int(20) } } 

Open in new window


foreach($mxhosts['mx'] as $smtp_host){
    if($socket = fsockopen($smtp_host, 25, $errno, $errstr, 20) )
    {
        break;
    }
}

Open in new window

0
Comment
Question by:mhdi
  • 2
3 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39876558
Where are Google's instructions that tell how to connect to its mail servers?  Can you post a link for us?  Thanks, ~Ray
0
 

Accepted Solution

by:
mhdi earned 0 total points
ID: 39880199
I found the issue. It was my hosting providers firewall blocking outbound connections initiated by PHP on port 25
0
 

Author Closing Comment

by:mhdi
ID: 39891402
Hosting provider issue found.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now