Thread tagged as: Problem, Error, Forms

Get Mailtrap working with live server


I can get Mailtrap working great with my local server (test email works and I can see it in their dashboard).

However, I cannot get it to work on a live site, getting an SMTP connect() failed message. FYI the hosting is GoDaddy (not my choice). I've seen someone had a similar problem here

I've tried changing the port number and also switching between SSL and TLS but unlike the person asking the other question I haven't found a different combination that works.

My question is what are the next steps for trying to get this to work? Where could I view diagnostics? How can I troubleshoot this?

Here are my Mailtrap settings that work locally:

define('PERCH_EMAIL_FROM', '');
define('PERCH_EMAIL_FROM_NAME', 'Jay George');

define('PERCH_EMAIL_METHOD', 'smtp');
define('PERCH_EMAIL_HOST', '');
define('PERCH_EMAIL_SECURE', 'tls');
define('PERCH_EMAIL_AUTH', true);
define('PERCH_EMAIL_PORT', 2525);
define('PERCH_EMAIL_USERNAME', 'xxx');
define('PERCH_EMAIL_PASSWORD', 'xxx');
Jay George

Jay George 2 points

  • 3 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

Depending on your (their) GoDaddy hosting plan, you may not be able to use an external SMTP server at all - they block everything. If it's a basic plan, you can only use a GoDaddy SMTP server.

Thanks Duncan, I'll check with them and reply here when I receive an answer.

I've finally managed to get this working with their mail server, but only locally(!).

These are the sanitised GoDaddy details. Any idea why this would be working locally and not on the live server? When going to the admin > Settings > Email and testing, I get a SMTP connect() failed. message.

define('PERCH_EMAIL_FROM', '');
define('PERCH_EMAIL_FROM_NAME', '');

define('PERCH_EMAIL_METHOD', 'smtp');
define('PERCH_EMAIL_HOST', '');
define('PERCH_EMAIL_SECURE', 'ssl');
define('PERCH_EMAIL_AUTH', true);
define('PERCH_EMAIL_PORT', 465);
define('PERCH_EMAIL_PASSWORD', 'xxx');

Jay, were you able to get the email working on the live site with perch default setup before adding the mailtrap smtp settings?

I always like to setup perch or runway default then begin to dress it out with options, this way I know I am troubleshooting the additions and not perch itself.

BTW, My default setup uses mailtrap for dev, both online and local and works great, so I can say it works.... just cant seem to see why not in your case.

Thanks Robert. If I just leave the email from and and from name in, sending a "test email" works, but oddly sending an admin notification after a form has been submitted does not work.

Do you know if the "Email test" and form submission use different methods to send an email?

Jay George said:

Thanks Robert. If I just leave the email from and and from name in, sending a "test email" works, but oddly sending an admin notification after a form has been submitted does not work.

Do you know if the "Email test" and form submission use different methods to send an email?

Both use PerchEmail.class, which decides the method based on whats available on the server and settings. So if one works the other should too... so I have to think this is a setting error on the Forms App. First go with the simplest test of Sending a Notice to admin of submitted form, then progress to adding autoreply... and so on. Also, If you have the members app installed... Is it working to send Moderator Email for new member signup, as this again will use the same methods as the Forms app would to send email. At least this way you can determine if ANY apps can send email.

My contact form settings in the admin are very simple so I'm not sure why it wouldn't work :-/

Here is a screenshot of the settings:

Is there some other way to debug what happens when the form gets submitted? This stuff is a bit beyond me and I'm not sure where else to go with it.

FYI I temporarily turned on define('PERCH_DEBUG', true); on the live site but couldn't see any sort of errors when I submitted a contact form. Although I'm not sure if anything should normally show there if something fails.

Ah ok, I realised how you can output the debug on the page. Once the form has been submitted this is the full debug I get:

SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_forms WHERE formKey='form-contact' LIMIT 1
[1] SELECT * FROM perch3_pages WHERE pagePath='/contact.php' LIMIT 1
    [fields] => Array

    [files] => Array

    [page] => Array
            [id] => 9
            [title] => Contact
            [path] => /contact.php
            [navtext] => Contact

Building message with Dollar template
Sent email: "New Enquiry" to
INSERT INTO perch3_forms_responses(responseJSON,formID,responseIP,responseSpamData) VALUES('{\"fields\":{\"name\":{\"attributes\":{\"id\":\"name\",\"type\":\"text\",\"required\":\"true\",\"label\":\"Name\"},\"value\":\"Jay George\"},\"email\":{\"attributes\":{\"id\":\"email\",\"type\":\"email\",\"required\":\"true\",\"label\":\"Email\"},\"value\":\"\"},\"message\":{\"attributes\":{\"type\":\"textarea\",\"id\":\"message\",\"required\":\"true\",\"label\":\"Message\"},\"value\":\"Test enquiry from live site\"}},\"files\":[],\"page\":{\"id\":\"9\",\"title\":\"Contact\",\"path\":\"\\/contact.php\",\"navtext\":\"Contact\"}}','1','','{\"fields\":[],\"environment\":{\"PATH\":\"\\/usr\\/local\\/jdk\\/bin:\\/usr\\/kerberos\\/sbin:\\/usr\\/kerberos\\/bin:\\/usr\\/local\\/sbin:\\/usr\\/local\\/bin:\\/sbin:\\/bin:\\/usr\\/sbin:\\/usr\\/bin:\\/usr\\/X11R6\\/bin:\\/usr\\/local\\/bin:\\/usr\\/X11R6\\/bin:\\/root\\/bin:\\/opt\\/bin\",\"SCRIPT_NAME\":\"\\/contact.php\",\"REQUEST_URI\":\"\\/contact.php\",\"QUERY_STRING\":\"\",\"REQUEST_METHOD\":\"POST\",\"SERVER_PROTOCOL\":\"HTTP\\/1.1\",\"GATEWAY_INTERFACE\":\"CGI\\/1.1\",\"REMOTE_PORT\":\"50145\",\"SCRIPT_FILENAME\":\"\\/home\\/somehosting\\/public_html\\/contact.php\",\"SERVER_ADMIN\":\"\",\"CONTEXT_DOCUMENT_ROOT\":\"\\/home\\/somehosting\\/public_html\",\"CONTEXT_PREFIX\":\"\",\"REQUEST_SCHEME\":\"http\",\"DOCUMENT_ROOT\":\"\\/home\\/somehosting\\/public_html\",\"REMOTE_ADDR\":\"\",\"SERVER_PORT\":\"80\",\"SERVER_ADDR\":\"\",\"SERVER_NAME\":\"\",\"SERVER_SOFTWARE\":\"Apache\",\"SERVER_SIGNATURE\":\"\",\"LD_LIBRARY_PATH\":\"\\/usr\\/local\\/apache\\/lib\",\"HTTP_COOKIE\":\"PHPSESSID=71n1ckksn7ndc9qst2uue2i231; cmsa=1; _ga=GA1.3.1449366876.1507828533; _gid=GA1.3.724312454.1508023288; _gat_gtag_UA_100849863_1=1\",\"HTTP_ACCEPT_LANGUAGE\":\"en-US,en;q=0.8,de;q=0.6\",\"HTTP_ACCEPT_ENCODING\":\"gzip, deflate\",\"HTTP_REFERER\":\"https:\\/\\/\\/contact.php\",\"HTTP_DNT\":\"1\",\"HTTP_ACCEPT\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,image\\/webp,image\\/apng,*\\/*;q=0.8\",\"HTTP_USER_AGENT\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/61.0.3163.100 Safari\\/537.36\",\"CONTENT_TYPE\":\"application\\/x-www-form-urlencoded\",\"HTTP_UPGRADE_INSECURE_REQUESTS\":\"1\",\"HTTP_ORIGIN\":\"https:\\/\\/\",\"HTTP_CACHE_CONTROL\":\"max-age=0\",\"CONTENT_LENGTH\":\"209\",\"HTTP_CONNECTION\":\"close\",\"HTTP_HOST\":\"\",\"UNIQUE_ID\":\"WeM0di78zZMABiUafaUAAAJH\",\"FCGI_ROLE\":\"RESPONDER\",\"PHP_SELF\":\"\\/contact.php\",\"REQUEST_TIME_FLOAT\":1508062326.805,\"REQUEST_TIME\":1508062326}}')
[1] SELECT * FROM perch3_forms_responses WHERE responseID='40' LIMIT 1
No ids to log.
Using template: /templates/pages/attributes/seo.html
[5] SELECT regionKey, regionHTML FROM perch3_content_regions WHERE regionPage='/contact.php' OR regionPage='*' ORDER BY regionPage DESC
[6] SELECT * FROM perch3_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch3_pages WHERE pagePath='/contact.php' LIMIT 1
[1] SELECT pageID FROM perch3_pages WHERE pageTreePosition IN ('000-007', '000') ORDER BY pageTreePosition DESC
[6] Using template: /templates/navigation/item_header_limit_and_more.html
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch3_content_regions WHERE regionKey='Partners' AND (regionPage='/partners.php' OR regionPage='*')
[7] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch3_content_index idx JOIN perch3_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch3_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=21 AND idx.itemRev=49)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
[7] Using template: /templates/content/partners/partner_listing.html
[1] SELECT groupID FROM perch3_navigation WHERE groupSlug='footer' LIMIT 1
[nil] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch3_navigation_pages np, perch3_pages p WHERE p.pageID=np.pageID AND np.groupID=1 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like the email is being sent.

Building message with Dollar template

Sent email: "New Enquiry" to

INSERT INTO perch3_forms_responses

As Drew says, it looks as if the message has been sent, and then perch goes on to store the form submission in the database.

Duncan Revell

Duncan Revell 78 points
Registered Developer


I don't know if this will help (especially with the test working but the form not working), but I had trouble helping someone out with GoDaddy. It wasn't Perch, but was using PHPMailer - the host I ended up having to use was the full, internal mail server name - like the following:

Before that I was getting the same error as you though. You can find the full name from somewhere in the cpanel.

Google Search: using mailtrap with godaddy


Some hosts, such as GoDaddy, block all SMTP ports, or don't allow using an SMTP server other than their own. A lot of mail services, such as Mandrill, Mailgun, Sparkpost, etc. provide both an SMTP server and a REST API for accepting email. Providing a REST API endpoint for accepting email would allow users on such restrictive hosts to be able to use mailtrap, even when they can't use the SMTP server.

link to result

Thanks both, that somewhat clears up why I'm having issues.

It still doesn't explain why I'm not receiving any of the notification emails while Perch is claiming they've been sent. I've tried changing the the send-to address and checking spam, but nothing ¯_(ツ)_/¯.

I do not have access to the cPanel for this client (it's with their IT company) so at the moment I've asked for the full internal server name as Duncan suggested.

Let's see if that changes anything.