Warning: mail() on contact page

Modern, responsive, unique and elegant one-page WordPress theme to showcase your creativity
GK User
Mon Dec 09, 2013 12:06 am
Tested it and I got this message:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\virtualservers\......\......\wwwroot\wp-content\themes\Creativity\layouts\gkcontact.php on line 105
User avatar
Expert Boarder

GK User
Mon Dec 09, 2013 8:11 am
It looks like your hosting server is missing one of quite important things - ability to send mails without using of 3rd party email server. Ill ask our dev team how to fix that.
User avatar
Moderator

GK User
Mon Dec 09, 2013 8:26 am
It seems like its more WP problem than our template. If you need to make it work, and your hosting company don't support local sendmail, you need to find a plugin, that changes WP's internal mail methods to use 3rd party smtp server.

After that you need also to edit this file:
wp-content/themes/Creativity/template.contact.php
and change:
Code: Select all
         mail($output['email'], $subject, $body, $headers);

to
Code: Select all
         wp_mail( $output['email'], $subject, $body, $headers);
User avatar
Moderator

GK User
Mon Dec 09, 2013 9:47 pm
I was told by my hosting provider to install mail plugin to send the emails through my website and to make sure to use their SMTP host address. Can you please recommend a mail plugin that I should install?
User avatar
Expert Boarder

GK User
Tue Dec 10, 2013 4:51 pm
If you will make the change I have mentioned, then You can use:
http://wordpress.org/plugins/wp-mail-smtp/
User avatar
Moderator

GK User
Tue Dec 10, 2013 9:14 pm
I did everything you suggested above. Then I got this message:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\virtualservers\......\......\wwwroot\wp-content\themes\Creativity\layouts\gkcontact.php on line 105.

So I went to the file on line 105 and edited:
$state = mail($email, $subject, $body, $headers)

to now:
$state = wp_mail($email, $subject, $body, $headers)


Now, I got this message: An error occured - your message has not been sent. Please try again. Help!
User avatar
Expert Boarder

GK User
Wed Dec 11, 2013 10:59 pm
Can somebody send me a reply to my last message?
User avatar
Expert Boarder

GK User
Thu Dec 12, 2013 6:40 pm
Every time you bump up (replay to your own message) it goes down in my queue and you wait longer.

The problem is with wp_mail function that doesn't work well with headers that are provided not as an array.

So you need to search in both files for this line:
Code: Select all
$headers = 'From: '.$output['name'].' <'.$output['email'].'>' . "\r\n" . 'Reply-To: ' . $output['email'] . "\r\n" . 'Content-type: text/html' . "\r\n";

and replace it with:
Code: Select all
$headers[] = 'From: '.$output['name'].' <'.$output['email'].'>';
$headers[] = 'Reply-To: ' . $output['email'];
$headers[] = 'Content-type: text/html';
User avatar
Moderator

GK User
Thu Dec 12, 2013 9:20 pm
I am still getting the same message: An error occured - your message has not been sent. Please try again.

Again, help!
User avatar
Expert Boarder

GK User
Sun Dec 15, 2013 12:07 pm
Perhaps there is a problem with configuration or the plugin. With changes presented above our theme is 100% compatible with wp mail system. You can check if WP is sending emails correctly by enabling comments and setting an option that comments need to be approved by administrator in articles, and then submitting a comment as a not logged in user.
After that please write back if email delivers correctly or not.
User avatar
Moderator

GK User
Tue Dec 17, 2013 1:25 am
Despite the changes suggested above, the same error message was produced. Help!
User avatar
Expert Boarder

GK User
Tue Dec 17, 2013 7:50 am
But does WP sent confirmations about comments correctly?
User avatar
Moderator

GK User
Sat Mar 08, 2014 4:36 am
It might sound a little stupid - but finding out is this a problem with our template (then comment confirmations will work), or with the plugin (then will not work), or maybe with its configuration is the first step do find the cause of the problem.
Sadly - you are our first customer who has hosting that doesn't support standard php mail command. I might say that is a standard and just should be there, but as far as I know this kind of cases - forcing hosting to provide standard mail command might be a mission impossible - we will try to do as much as we can on our side, but I can't guarantee 100% success.
User avatar
Moderator

GK User
Sat Mar 08, 2014 4:42 am
Hi again - It's been awhile since I left this topic. I checked with my mail server and apparently the SMTP is working fine. They think it's the contact form settings that needs to be fixed. Help! Let me know if you need to check the website's contact form but I can only give it to you through a Private Message. Thanks!

BTW, this is the message I get after clicking Submit of the contact form: An error occured - your message has not been sent. Please try again.
User avatar
Expert Boarder

GK User
Sat Mar 08, 2014 4:59 am
Cyberek wrote:Every time you bump up (replay to your own message) it goes down in my queue and you wait longer.

The problem is with wp_mail function that doesn't work well with headers that are provided not as an array.

So you need to search in both files for this line:
Code: Select all
$headers = 'From: '.$output['name'].' <'.$output['email'].'>' . "\r\n" . 'Reply-To: ' . $output['email'] . "\r\n" . 'Content-type: text/html' . "\r\n";

and replace it with:
Code: Select all
$headers[] = 'From: '.$output['name'].' <'.$output['email'].'>';
$headers[] = 'Reply-To: ' . $output['email'];
$headers[] = 'Content-type: text/html';



Hi - I forgot which two files I went to check for this one. Can you please mention it here? Thanks!
User avatar
Expert Boarder

GK User
Sat Mar 08, 2014 9:41 am
/wp-content/themes/Creativity/template.contact.php
/wp-content/themes/Creativity/layouts/gkcontact.php
User avatar
Moderator

GK User
Sat Mar 08, 2014 8:29 pm
Cyberek wrote:/wp-content/themes/Creativity/template.contact.php
/wp-content/themes/Creativity/layouts/gkcontact.php


Is there anything else that needs to be fixed here? In the ....../template.contact.php, this is what I got:

if($params_name && $params_email) {
$headers[] = 'From: '.$output['name'].' <'.$output['email'].'>';
$headers[] = 'Reply-To: ' . $output['email'];
$headers[] = 'Content-type: text/html';
} else if($params_name && !$params_email) {
$headers = 'From: '.$output['name']. "\r\n" . 'Content-type: text/html' . "\r\n";
} else if(!$params_name && $params_email) {
$headers = 'From: '.$output['email'].' <'.$output['email'].'>' . "\r\n" . 'Reply-To: ' . $output['email'] . "\r\n" . 'Content-type: text/html' . "\r\n";
} else {
$headers = 'Content-type: text/html' . "\r\n";
}

mail($email, $subject, $body, $headers);

if($params_copy && $params_email && isset($_POST['send_copy'])) {
wp_mail($output['email'], $subject, $body, $headers);
}

$messageSent = true;
}
User avatar
Expert Boarder

GK User
Tue Mar 11, 2014 7:23 pm
Code: Select all
if($params_name && $params_email) {
$headers[] = 'From: '.$output['name'].' <'.$output['email'].'>';
$headers[] = 'Reply-To: ' . $output['email'];
$headers[] = 'Content-type: text/html';
} else if($params_name && !$params_email) {
$headers = 'From: '.$output['name']. "\r\n" . 'Content-type: text/html' . "\r\n";
} else if(!$params_name && $params_email) {
$headers[] = 'From: '.$output['email'].' <'.$output['email'].'>' . "\r\n" . 'Reply-To: ' . $output['email'] . "\r\n" . 'Content-type: text/html' . "\r\n";
} else {
$headers[] = 'Content-type: text/html' . "\r\n";
}

wp_mail($email, $subject, $body, $headers);

if($params_copy && $params_email && isset($_POST['send_copy'])) {
wp_mail($output['email'], $subject, $body, $headers);
}

$messageSent = true;
}
User avatar
Moderator

GK User
Tue Mar 11, 2014 7:25 pm
From what I see you might just update the template - the fix should be implemented by now.
User avatar
Moderator

GK User
Fri Mar 14, 2014 10:49 pm
If I update the template, does that mean I have to start from square one? Or, are specific files that were only updated that you could provide me with?
User avatar
Expert Boarder

GK User
Mon Mar 17, 2014 11:57 am
With the current version/update this changes are included.
User avatar
Moderator

GK User
Mon Mar 17, 2014 7:35 pm
I've updated the version and yet I still have the same problem. One of your moderators, teitbite, is helping me out on this. Is it possible that if this is not resolved, I could create my own contact form from scratch (not even using any contact plugins since I tried this and it didn't work either)? Then, do I have to change anything in the Settings and Template options? Help!
User avatar
Expert Boarder

GK User
Tue Mar 18, 2014 11:05 am
Please let Teitbite check whats wrong on your site.
If you will try to create your custom contact form, still you will need to make mail go out from your server and as far as I can see this is still an issue.
Could you confirm, that now, after installing wp-mail-smtp plugin you receive informations from wp (info about added comment for example - you need to configure that in wp options)?
User avatar
Moderator

GK User
Tue Mar 18, 2014 11:01 pm
After activating the WP Mail Smtp plugin and filled out the Advanced Email Options, the Send Test Email was a success. I received this message: "This is a test email generated by the WP Mail SMTP WordPress plugin." in To Email add I provided. Therefore, I think it's the contact form that has the problem and teitbite is saying that I have to contact my host provider which now makes this confusing for me because my host provider already told me that it's the contact form not the smtp connection that needs fixing.
User avatar
Expert Boarder

GK User
Wed Mar 19, 2014 8:15 am
Please check if WP can send notification from comments. Sending test email from a plugin is one thing, sending it from the system is something different.
User avatar
Moderator

GK User
Wed Mar 19, 2014 7:53 pm
The comments are working just fine.
User avatar
Expert Boarder

GK User
Fri Mar 21, 2014 4:11 pm
So you get notification about new comments on your mail?
User avatar
Moderator

GK User
Sat Mar 22, 2014 8:52 am
I get notifications on comments only on Wordpress and NOT in the mail/email.
User avatar
Expert Boarder

GK User
Mon Mar 24, 2014 7:58 am
Did you set the comment notification to be delivered by mail? (there is an option in comments settings that administrator need to approve comments. if you check it, it will send an email every time someone not logged in will add a comment - please check that).
User avatar
Moderator

GK User
Tue Mar 25, 2014 1:19 am
Already done before.

Discussion Settings > Email me whenever > Anyone post a comment and A comment is held for moderation (both tick marked)
User avatar
Expert Boarder

GK User
Wed Mar 26, 2014 8:30 pm
So it looks like smtp plugin problem. If wp can't communicate with normally, our theme will not be able also. Maybe try any other remote smtp plugin available in the wp plugins repository?
User avatar
Moderator


cron