aspose file tools
The moose likes PHP and the fly likes phpmailer. can not connect to server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "phpmailer. can not connect to server" Watch "phpmailer. can not connect to server" New topic

phpmailer. can not connect to server

sahar eb
Ranch Hand

Joined: May 06, 2009
Posts: 38
I have this contact.php file which processes the data coming from a form. This file tries to send the entered information to an email using PHPMailer (If they are validated). here is the code snippet:

and here is the error it throws:

I am new at this so please give me a clear answer or examples! I have searched a lot, but still couldn't solve it!
any help or suggestion would be deeply appreciated!
Thank you so much!

Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

Here are a couple of suggestions:

1) Are you sure you have the correct hostname? Try doing


and see if you get a result. (The name lookes starnage to me, usually the last part should be .com)

2) Are you sure that port 25 is open and not blocked by a firewall? Try this to see if the port is accessible:

telnet 25

If it accessible you will get some result (gibbersh, screen refresh). If the port is not accessible, you will get a connection error.

3) Are you sure you have the correct username and password ( to connect to mail server? Some mail servers only want the name and not the "@hostname" portion to log in.

4) Do you own If so, what OS is it running? If you don't own it, are you sure that you have access to it? I ask because if that site is running MS Exchange you might not have the necessary access rights (I run into that all the time at work - I cannot programmatically access the same Exchange server that Outlook has access to so we have configured a gateway system that we use when testing email code or configuring other apps to send emails).
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: phpmailer. can not connect to server