Results 1 to 7 of 7

Thread: Does Hostmonster blocked it's 25 port for smtp?

  1. #1
    Join Date
    Feb 2009
    Posts
    8

    Exclamation Does Hostmonster blocked it's 25 port for smtp?

    I am testing the email sending function with PHP on hostmonster. Swift mailer is the library i am using.

    But it turned out that i can only send email with smtp server WITHIN hostmonster (whose port is 26, not 25 as usual).

    I trued many other free smtp servers gmail, tom.com, yeah.net....

    The code is as following...

    Code:
                require_once "lib/Swift.php";
                require_once "lib/Swift/Connection/SMTP.php";
    
    
                //Connect to Gmail (PHP5)
                $smtp = & new Swift_Connection_SMTP("smtp.gmail.com"
                   , Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_SSL);
                
                $smtp->setUsername("username");
                $smtp->setpassword("password");
    
                $smtp->setTimeout(120);
    
                $swift = new Swift($smtp);
                $message =& new Swift_Message("My subject", "My body");
    
                if ($swift->send($message, "recep@gmail.com", "sender@gmail.com")) echo "Sent";
                else echo "Failed";
    The message i got:


    Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [mail.bellsouth.net:25]: fsockopen returned Error Number 111 and Error String 'Connection refused'' in /home/bashanpi/public_html/ezdict/sender/lib/Swift/Connection/SMTP.php:309 Stack trace: #0 /home/bashanpi/public_html/ezdict/sender/lib/Swift.php(216): Swift_Connection_SMTP->start() #1 /home/bashanpi/public_html/ezdict/sender/lib/Swift.php(101): Swift->connect() #2 /home/bashanpi/public_html/ezdict/sender/index.php(23): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in /home/bashanpi/public_html/ezdict/sender/lib/Swift/Connection/SMTP.php on line 309
    FYI: i can send email from my PC to my gmail, i can send email through the hostmonster hosted smtp to gmail. But i can not send email from php code on hostmonster.

    I am now thinking that hostmonster may blocked port 25 on its servers to prevent spam.

    Please help!

  2. #2
    Join Date
    May 2007
    Location
    Wellington, New Zealand
    Posts
    827

    Default

    Shouldn't the line
    Code:
    $smtp = & new Swift_Connection_SMTP("smtp.gmail.com"
    read
    Code:
    $smtp = & new Swift_Connection_SMTP("localhost"
    You are attempting to connect to Gmail's SMTP server from your code which is blocked by Hostmonsters firewall for shared IP addresses. Set it to localhost and you should be fine.

  3. #3
    Join Date
    Feb 2009
    Posts
    8

    Default Thanks for reply!

    Thanks a lot! That works!

    So that means I can not use gmail smtp server to send mail but just hostmonster?

    And i only changed the server address, but not the port number to gmail, so it reads

    Code:
                $smtp = & new Swift_Connection_SMTP("localhost"
                   , Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_SSL);
    PORT_SECIRE is 465, so that means 465 port and SSL will also work in localhost? Weird to me.

    As you said it is prevented in shared ip addresses? So an independent ip will be able to send through gmail?

    Why hostmonster do so? Preven spam? Yes one spammer may cause all websites on that server blocked by gmail. But send through localhost will cause the same type of problems as well.

    Anyways, my problems solved, thanks!

  4. #4

    Default

    That sounds correct. If you get a private (dedicated) IP address, you get full control over what ports are allowed in and out of your account.

    As far as spam, Hostmonster is fairly strict. I am not aware of all the protections they have on their severs to prevent their users from spamming, but each one is limited to a default of 50 outgoing emails per hour up to a max of 500 (with a good reason).

    They also do other things, like not allow an account of theirs to go outside their own smtp servers unless the MX records indicated it is allowed (as in the case of google apps, etc).

    Again, I'm not 100% sure about your statement of the independent ip being able to send through gmail, unless gmail was set up as the MX host for your email, but it seems plausible ... besides, it's late ... and what do I know?

    ~regards, glad to hear you got it working.
    He is no fool that gives what he cannot keep to gain what he cannot lose. - Jim Elliot
    4ChristMinistry.org - Web development tutorials and Community forum.
    Demos - Kicking the tires on some popular software.

  5. #5
    Join Date
    May 2007
    Location
    Wellington, New Zealand
    Posts
    827

    Default

    My question is why do you want/need to send the email through Gmail's SMTP server? I can't see much benefit personally but maybe there's a feature of doing that that you need?

  6. #6
    Join Date
    Feb 2009
    Posts
    8

    Default

    Simply, because I copied the code from swift mailer. And it indeed looks nice to send through Gmail with SSL. That's it. And I did not see any problem with that and did not know the localhost will simply do it eigther, before some one told me.

    First time to touch this kind of stuff. Good to play around and learn, right?

  7. #7
    Join Date
    Dec 2008
    Posts
    10

    Default

    Change the code to Localhost

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
  •  
ankara escort