Page 1 of 1

HELP, unable to use Swift in SMTP mode

Posted: Sat Jan 10, 2009 11:29 pm
by iosoft
Hi

The problem is little strange.
If I use 'localhost' as mail server then SUCCESS, but if I use 'mail.mydomain.net' it fails.

Code: Select all

try {
$mailer = new Swift(new Swift_Connection_SMTP( 'mail.mydomain.net', SWIFT_DEFAULT_PORT, SWIFT_OPEN));
 
} catch (Swift_ConnectionException $e) {
    print_r($e->getMessage());
}
SWIFT Error says -
NOT CONNECTED !!
PHPMailer says -
Warning: fsockopen() [function.fsockopen]: unable to connect to mail.gigahertz.net.in:25 (Connection timed out) in /home/gigahert/public_html/includes/phpmailer/class.smtp.php on line 105
SMTP -> ERROR: Failed to connect to server: Connection timed out (110) Error:SMTP Error: Could not connect to SMTP host.
Can you please suggest me how can I solve this problem ?
I want to allow both 'localhost' and 'mail.mydomain.net' for sending mails.

NOTE:
System: Linux
Server: Apache
Script: PHP5
Web-Server and Mail-Server are in same PC.

Re: HELP, unable to use Swift in SMTP mode

Posted: Sun Jan 11, 2009 12:30 am
by Chris Corbyn
Sounds as though you have a firewall running. I can connect to mail.gigahertz.net.in on port 25 just fine from here ;)

Re: HELP, unable to use Swift in SMTP mode

Posted: Sun Jan 11, 2009 1:08 am
by iosoft
Can yo pls tell me how you are connecting with my SMTP server ?
and What should I ask my Provider to do ?

Re: HELP, unable to use Swift in SMTP mode

Posted: Sun Jan 11, 2009 2:17 am
by Chris Corbyn
I used telnet on the command line. It just opens a TCP terminal session to any remote server on the port you tell it. In this case your SMTP server on port 25.

If you know SMTP you can can send emails in the way if you're sad and geeky enough ;) It's basically all Swift Mailer does under the surface:

Code: Select all

- $ telnet mail.gigahertz.net.in 25
Trying 208.43.209.220...
Connected to gigahertz.net.in.
Escape character is '^]'.
220-scorpio.hrn9.com ESMTP Exim 4.69 #1 Sun, 11 Jan 2009 11:59:59 +0530 
220-We do not authorize the use of this system to transport unsolicited, 
220 and/or bulk e-mail.
quit
221 scorpio.hrn9.com closing connection
Connection closed by foreign host.
- $
The lines starting in 220 are the successful greeting lines of a SMTP session. The 221 line is the "goodbye" of an SMTP session.

In your case Swift can't even get as far as seeing 220. It won't connect at all. Firewall by the sound of it.

Re: HELP, unable to use Swift in SMTP mode

Posted: Sun Jan 11, 2009 2:59 am
by iosoft
Yes, I know little-bit of the TELNET to SMTP thing but didn't tested that way.

Now as you suggested....
I TELNET to my Mail-Server : Connection Success
then,
I connect to my Server using SSH and from there ran TELNET to my Mail-Server : Connection Failed (Time-out)

I reported my Hoster, they say -
You might be getting this error in mail.mysite.net.in because the DNS record for this url is set us Cname entry of the domain and when you are using localhost there are no such issues so either use local host or the server ip for php mailer.
Suggestion....

Re: HELP, unable to use Swift in SMTP mode

Posted: Sun Jan 11, 2009 4:20 am
by Chris Corbyn
They've got firewall rules in place, or they've got a routing issue. If you can't connect from SSH then you can't connect from a PHP script ;)

Does "localhost" point to the server "mail.gigahertz.net.in" or is mail.gigahertz.net.in a different server? If it's the same server some routers don't play well with looping back to yourself but that's something for your ISP to resolve.

I'm afraid there's nothing else I can do here, as you can see it's the server so you'll need to let your host resolve it.

Re: HELP, unable to use Swift in SMTP mode

Posted: Tue Jan 20, 2009 6:40 am
by iosoft
Thank you very much for your kind support+help+suggestion :D

Re: HELP, unable to use Swift in SMTP mode

Posted: Tue Jan 20, 2009 9:40 pm
by iosoft
My Last question -

Will there be any big issue if I use SMTP server as 'localhost' ?
My web-server and mail-server is same shared server.

Re: HELP, unable to use Swift in SMTP mode

Posted: Tue Jan 20, 2009 10:30 pm
by Chris Corbyn
iosoft wrote:My Last question -

Will there be any big issue if I use SMTP server as 'localhost' ?
My web-server and mail-server is same shared server.
That should work fine if the SMTP server is configured this way :)

Re: HELP, unable to use Swift in SMTP mode

Posted: Tue Jan 20, 2009 10:39 pm
by iosoft
Thanks :drunk: