PHPMailer and smtp on 1and1 shared hosting
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.
Alan said,
April 9, 2008 at 3:45 pm
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
Matt said,
April 22, 2008 at 9:42 pm
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!
Matt said,
April 22, 2008 at 9:52 pm
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
Simo said,
April 25, 2008 at 5:00 pm
Thanks for the tip Matt.
Duncan said,
May 21, 2008 at 7:27 am
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
Ares said,
May 22, 2008 at 12:39 am
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.
Simo said,
May 22, 2008 at 12:49 am
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.
graz said,
December 15, 2008 at 12:23 pm
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
David said,
December 30, 2008 at 7:41 pm
Thank you! You are a savior!
mike said,
February 16, 2009 at 7:15 pm
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.
Eduardo Bortoluzzi said,
February 18, 2009 at 9:15 am
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
Sebastien G. said,
April 20, 2009 at 10:48 am
Wow… just tried the isSendEmail thing… and it worked… after freaking like 4 hours of researches…
thks a LOT !
Cameron said,
July 3, 2009 at 8:41 am
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,
July 3, 2009 at 8:57 am
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,
July 3, 2009 at 9:37 am
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?
Cameron said,
July 3, 2009 at 9:01 am
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?
Simo said,
July 3, 2009 at 1:21 pm
I can’t really tell by the line you sent me.. and even that line has nothing wrong with it really. if you can get to the command line and type:
php -v
that would return the version info of php that 1and1 uses.
Also it might help to replace phpmailer.php with the latest version which you can get from : http://downloads.sourceforge.net/sourceforge/phpmailer/PHPMailer-ML_v1.5.zip?use_mirror=superb-east
Hope this helps..