PHPMailer and smtp on 1and1 shared hosting

March 2, 2008 at 1:08 pm (How it's Done: Tips and Snippets?) ()

I use phpMailer on my 1and1 shared hosting account. Recently, I could not send email anymore.

I tried debugging and this is the error that phpMailer throws:

Language string failed to load: connect_host

After googling for a solution and trying different smtp servers, accounts and smtp ports, I decided to switch to sendmail and it worked like a charm! All I needed to do was replace $mail->isSmtp() with:

$mail->isSendMail()

sendMail is located in its default location on 1and1 servers : /usr/sbin/sendmail, so no change of settings was required.

Conclusion: 1and1 probably closed its outgoing smtp ports on its shared hosting servers. Consequently, if you use PhpMailer, don’t use smtp mode anymore.

17 Comments

  1. Alan said,

    I just discovered this problem while trying to install the latest PHPMailer, Version 2.0.0. Thankfully, SendMail seems to work as well as SMTP. I appreciate the tip!

    –Alan–

    Saint Louis, Missouri, USA

  2. Matt said,

    I have been using phpmailer for sometime now on other sites/hosts but a new project has brought me to 1and1 and to new problems! Made the change you mentioned and we have email functionality again! Also, thank you for specifically mentioning 1and1 since there are about a million posts on forums discussing the “connect_host” error message!

  3. Matt said,

    I just found a way to use SMTP with phpmailer on 1and1 server: you must use the IP address of the smtp server (74.208.5.2). Found solution at:

    http://www.forums.phplist.com/viewtopic.php?t=17493&view=previous&sid=6c2c1b3efce5d9b91f9555a96b08345d

  4. Simo said,

    Thanks for the tip Matt.

  5. Duncan said,

    After lots of hunting for the problem with my phpMailer, I stumbled upon this site. Figured might as well try it and……

    IT WORKED!

    So thanks for sharing

  6. Ares said,

    Up to how many people have you been successfully sending mail through PHPmailer?

    Ive been trying to send to 2300 but it just doest work. I am also with 1and1.

  7. Simo said,

    Ares..nope, don’t have an answer to that… your email could have failed for different reasons..but you can ask 1and1 directly and see if they put a cap on the number of recipients per email on their sendmail servers.

  8. graz said,

    HI guys, thank you for this thread, that has been quite useful. I am actually using the 1and1 SMTP server as a relay: a PHP app connects to the 1and1 SMTP server to send e-mails to a set of subscribers. I had some initial problems but eventually everything seems to be ok (this scenario, however, is a bit different than the scenario you describe as my “client” is not hosted by 1and1 yet). As you say, 1and1 probably closed its outgoing smtp ports on its shared hosting servers. However, the following properties setting may be of help:
    $mail->IsSMTP();
    $mail->SMTPAuth = true; // enable SMTP authentication
    $mail->Host = “auth.smtp.1and1.co.uk”;
    $mail->Port = 25; // set the SMTP port
    // do not set $mail->SMTPSecure !
    -of course-
    you will need to assign $mail->Username and $mail->Password

    With this configuration I could consume the SMTP server of 1and1 (uk based, at least).
    Last: I have seen that you are using the IP address instead of a hostname – the different behaviour, likely, is not because PHPmailer but it should be due to the overhead in looking up – overhead that you avoid when using the IP address.

    Thank you for your post
    Regards
    daniel

  9. David said,

    Thank you! You are a savior!

  10. mike said,

    hey thanks for the solution — this worked like a charm on 1and1. we moved a site from a local server that kept crashing to 1and1 and this was the only script that kept failing.

  11. Eduardo Bortoluzzi said,

    Thank you very much for sharing the info, i just changed to isSendMail() and it works now, i was proper pissed off with that, waited till the last piece of pacience to change it to isSendMail… but there you go, try it if youre having problems with 1&1! they only had info about mail() and not phpmailer!

    Cheers

  12. Sebastien G. said,

    Wow… just tried the isSendEmail thing… and it worked… after freaking like 4 hours of researches…

    thks a LOT !

  13. Cameron said,

    I’m actually getting a different error:

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /homepages/13/d191942467/htdocs/includes/classes/phpmailer.php on line 87

    I am using the exact same script on many other sites that are not hosted with 1and1 and I’m thinking my host is the problem. I don’t know much about phpMailer, but I don’t have a $mail->isSmtp() or mail(). I’m only using phpMailer as a contact form, so it’s only trying to send one e-mail, which is supposed to come to me.

    Any help would be much appreciated.

    • Simo said,

      Looks like you have a script error which might be related to a different version of PHP on 1and1 servers..you might just want to upgrade your phpmailer version..can you send me the line at 87 of your phpmailer.php.

      • Cameron said,

        Thanks for the quick reply!

        public $Priority = 3;

        (This is the first line of the class after the declaration: “class PHPMailer { ” )

        I saw on another forum that a user received the same (or similar) error, and I looked into a different version. How do I tell which version of PHP 1and1 is running? Can you tell which one I have/should have based on the above info?

  14. Cameron said,

    Thanks for the quick reply!

    public $Priority = 3;

    (This is the first line of the class after the declaration: “class PHPMailer { ” )

    I saw on another forum that a user received the same (or similar) error, and I looked into a different version. How do I tell which version of PHP 1and1 is running? Can you tell which one I have/should have based on the above info?

Post a Comment