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 Build a Simple PHP Application Wrapping Up The Project Sending The Contact Form Email

Robert Mills
Robert Mills
16,243 Points

How To Use External Server Service (Postmark) With PHP To Deliver Contact Form Emails????

I am using an external server service to try and deliver my emails, but it is not working. When I use the server of my hosting company, the form is delivered without an issue. However, when I use Postmark as my server, when I hit the submit button I get a blank screen with no explanation of why the form was not delivered. You can try and submit the form at the URL below.

http://yknottoday.com/

I read the blog from Randy Hoyt and based on his recommendations and that of Postmark, the following code should work.

$mail->Host = "smtp.postmarkapp.com"; $mail->Port = 587; $mail->Username = "8bd31302-9925-4a8a-83e5-2f950e7db78e"; $mail->Password = "8bd31302-9925-4a8a-83e5-2f950e7db78e";

Randy Hoyt Postmark blog: http://blog.teamtreehouse.com/sending-email-with-phpmailer-and-smtp

Postmark Recommendations http://developer.postmarkapp.com/developer-send-smtp.html

I have used all of the port numbers:

25, 2525, 587

Additionally, I have used the API key as the Username and Password, which is what they stated needed to be done. I have tried implementing the Username and Passwords in those fields that I used to log into my account, which I felt was logical, but that didn't work either.

I feel as if I have exhausted all my options, can someone please help???????

7 Answers

I had the same issue.... The same settings and information for postmark worked on my local-server and postmark send the message, but did't work on the web-server.

I think this might have something to do with the host of the website. There is some option to verify your host at postmark in some way but i didn't try it yet. My webhost was hostinger.in.

Maybe you should write to postmark if you need to solve the problem quickly....if you get some answer bringing you close to something it would be cool of you could post it here, i'm very interested how this works with other webhosts.

Robert Mills
Robert Mills
16,243 Points

I contacted GoDaddy and even when the code is implemented correctly, the procedure that needs to be done to have the contact form go through an external server is above the users access level. The individual on the phone contacted the server admin and granted permission for my website to submit the contact form through an external server. From my understanding of the conversation the correct terminology for this procedure is to grant "Remote email access". Thanks for the direction, you helped me out a great deal, GoDaddy said the form should be working within the hour.

Robert Mills
Robert Mills
16,243 Points

Spoke a bit early, still working on it.

Did Godaddy fix it for you? I'm having the same issue.

I rang GoDaddy and they told me that they couldn't do anything and that it must be my code. They suggested that there is nothing wrong with my server's ability to send emails, so why don't I send it that way (i.e. don't go through PostmarkApp). Postmark, on the other hand, has told me that Godaddy blocks the ports that they use for SMTP and that if you want to use their service you have to send with API.

Interestingly, I tried what someone else suggested, removing the line $mail->IsSMTP(); , and it actually works!

Steven Del Rio
Steven Del Rio
17,746 Points

Hi,

I also removed the line $mail->IsSMTP(); and it successfully sent to my gmail. I'm happy it works but still confused. My host is still : $mail->Host = 'smtp.postmarkapp.com';

OK, I've just realised why it's working. I think removing that code makes the email bypass the PostmarkApp and sends it directly from your server. They receive the email, but you don't have access to any of the benefits of Postmark. It looks like I'll just have to try to figure out how to send email via API. Bummer... anyone got any tutorials? The documentation is over my head!

Mayur Pande
Mayur Pande
Courses Plus Student 11,711 Points

Did anyone manage to solve this issue? I am having exactly the same problem. I have spoken to both godaddy and postmark and they are both just batting me around!