Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

SMTP and hosting company

Hello y'all!

Basically I took up Randy Hoyt's advice and tried to use an external email server to handle the contact form on my website. I used PHPmailer as well. The way I set up the connection to this mailserver is as followed:

require_once("inc/packages/class.phpmailer.php");
            $mail = new PHPMailer();

            $mail->IsSMTP();               
            $mail->SMTPAuth = true;             
            $mail->SMTPSecure = "tls";                 
            $mail->Host = "smtp.gmail.com";     
            $mail->Port = 587;                 
            $mail->Username = "correctmail@gmail.com"; 
            $mail->Password = "totallysecure";

As you can see, I tried to use the gmail mail server (is that what I did? I'm new to this). Now, this totally worked on localhost, after changing some things in php.ini. I filled in my contact form, clicked send, and the mail arrived in my gmail inbox. Nice!

But then I uploaded it to my webhost, one.com. When I tried the form there, sending the form caused an error, saying it could not connect to the server.

When I contacted them, all they said was "You should use our smtp". Naturally, being a true internet freedomfighter, these words caused me to throw a tantrum.

What do you guys suggest I do?

2 Answers

Samuel Rueby
Samuel Rueby
22,538 Points

This won't be a great answer to your question but I think you will have way more success signing up for a free account at https://www.mandrill.com . You'll get like 12,000 emails/month before you have to pay for anything and the customer service is way better.

Thanks, yeah! (Any tips are welcome, I can only learn from them ;-))

I guess that for now I'll have to live with the fact that I have to use their email servers, as long as I can't connect to any others. The only positive thing about it is that apparently if I use their email services as well to send the e-mails to, I can send an unlimited amount.