Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Help with getting phpMailer to work on client's server.

I'm using phpMailer to power a contact form and it works great on my own server (through Bluehost) for testing purposes.

When I upload the same files to my client's server (through Century Link/Savvis), the 'thanks for contacting us' page appears, but the email never arrives to the inbox.

I know very little about servers aside from how to use FTP, but I'm assuming it must be an issue with my client's server? Something with permissions or some installation? How do I even begin to investigate that?

If it helps, the client's site is http://bearsbikebarn.com -- it's an old site from another designer and I was just brought in to make the contact form work again.

Thanks for any help!

3 Answers

Check the ports , check the firewall if there is an condition block this , if not try to use smtp

Ron McCranie
Ron McCranie
7,837 Points

You can try using the phpMailer class to send via SMTP using an existing email account on a server like Gmail. You could also setup a free Mandrill account and use some settings like this:

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.mandrillapp.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'foo_username';
$mail->Password = 'foo_password';
// if you have a subaccount
$mail->AddCustomHeader('X-MC-Subaccount:' . 'your_foo_subaccount');

Thanks for the suggestions. I got in touch with the hosting company and it turns out there had to be a special e-mail address in place in the "from:" field of the script for their servers to process it.

Ron McCranie
Ron McCranie
7,837 Points

That sounds about right. There's a way to whitelist/blacklist senders and recipients in the Postfix configuration. I've spent many hours this past week getting mine tuned just right.