Email form not working on new server

Issues related to forms.
Post Reply
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Email form not working on new server

Post by AndySwiny »

I was with IONOS I have now moved to Hostinger

Same site same forms if I do not use the built-in Php and send it to a second page use HTML to send the form all works okay
if I enable built-in Php I get confirmation page okay but no email is sent

Tests I did Hostinger have a test.php file to see if PHP mail() Function is enabled and working file that you can put onto the site to see if you get an email that confirms that Php is enabled and emails are received PHP mail() Function I did this and I received the email confirming that PHP mail function existed and worked

I would like to use the built-in PHP mail() Function but I do not know how to fix this problem
the coding your program worked on the last server and the new server says that there PHP mail function is working

Does anyone have any ideas where I could look to find where the problem is

Link to the page where it tells you about the PHP mail() Function
https://www.hostinger.com/tutorials/sen ... g-php-mail

thank you for your help Andy
User avatar
BaconFries
 
 
Posts: 5871
Joined: Thu Aug 16, 2007 7:32 pm

Re: Email form not working on new server

Post by BaconFries »

What version of the software are you using? What version of php are you using in the form and your server? If it previously worked on your old host and not on your new then it is a sever configuration. Please note that forms using php are processed on the server so the issue will be there. What does the error log say if any.
See the following url reading from Emails are not arriving in my inbox...
4. Most webhosts now require you to use SMTP authentication for forms.
viewtopic.php?f=10&t=32967
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

Thank you for your responce I am aware it is probably something to do with the new server as it worked before.
I am using version 17 PHP version for page is set to PHP5 - PHP8 the server IONOS used PHP8, the new server uses the same PHP8
The problem is as stated before I have run a test on the server and the server is set to send mail by PHP mail() Function.

So the server people state that it's not them, and I know your program works, so it's not you
BUT THAT IS NOT STOPPING IT NOT WORKING
So it is where do I look now, I have been using the program for many years and never had this problem. I have read the links and it does not shed light on my problem

Thank You Andrew I hope someone can point me in the right direction.
User avatar
Pablo
 
Posts: 23234
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Email form not working on new server

Post by Pablo »

Did you read and try all suggestions from the FAQ?
If you need further help then please check the PHP log, otherwise there is nothing we can do to help. Because there are too many variables.
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

hi yes read all
i was hoping some one on here was using Hostinger servers with built-in PHP and let me know what settings they were using, or did they have to do something on the server side.

Thanks Andrew
User avatar
BaconFries
 
 
Posts: 5871
Joined: Thu Aug 16, 2007 7:32 pm

Re: Email form not working on new server

Post by BaconFries »

I think there is a few using them it just a wait and see who replies. Maybe the following post will help.
https://wysiwygwebbuilder.com/forum/vie ... p?p=485418
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

Thank you i will try what he did i gat back to you
here is the PHP error log
[31-Jul-2023 21:18:50 UTC] mail() on (The * to hide info) [/home/******/********/davina-andrew-photography.co.uk/public_html/other/enquires.php:89]: To: davina@davina-andrew-photography.co.uk -- Headers: From: *************@andrewswinfield.plus.com Reply-To: ************@andrewswinfield.plus.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="877b2d07e2453da55d8f477d6f7467dc" X-Mailer: PHP v8.0.28 -- Subject: Enquire
User avatar
Pablo
 
Posts: 23234
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Email form not working on new server

Post by Pablo »

Is this the full PHP error log? There is no useful information is this :(
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

Update of extensive testing

On form set Accept charset to IOS-8859-1 Target to _top ( Do not set a successful page ) set Built-in PHP advanced tab Mail Engine tick the box mail engine SET to sendmail

I now received the mail

The problem now is that if you set a successful page it does not work

Further testing
when using mail engine tick box 3 files are uploaded
Exception.php
SMTP.php
PHPMailer.php

All these files or only PHP 5.5

On further reading there is an update for these files can you supply the updates for these files as it states that 5.5 does not work with version 8 PHP

Thanks Andy
User avatar
Pablo
 
Posts: 23234
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Email form not working on new server

Post by Pablo »

The included PHP Mailer files are the latest versions (6.8.0), they are compatible with PHP 8. There is no newer version of PHP Mailer.

If the form does not work then please share the content of the PHP error log otherwise there is nothing meaningful I can say about what is going on.
The built-in form processor works for all other user so I am sure it can also work for you, if correctly configured,.
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

The files that were uploaded to the website from the program or only version 5.5 PHP

Exception.php
PHPMailer Exception class.
* PHP Version 5.5.

SMTP.php
PHPMailer RFC821 SMTP email transport class.
* PHP Version 5.5.

PHPMailer.php
PHPMailer - PHP email creation and transport class.
* PHP Version 5.5.

Is this why am having problems I got an old version of these files somehow can you supply the new version

Here is the log

Stack trace:
#0 {main}
thrown in /home/*******/domains/**********/public_html/other/enquires.php on line 4
[01-Aug-2023 06:58:31 UTC] PHP Warning: require(/home/*******/domains/**************/public_html/other/Exception.php): Failed to open stream: No such file or directory in /home/******/domains/**************/public_html/other/test.php on line 4
[01-Aug-2023 06:58:31 UTC] PHP Fatal error: Uncaught Error: Failed opening required '/home/*********/domains/***********/public_html/other/Exception.php' (include_path='.:/opt/alt/php80/usr/share/pear:/opt/alt/php80/usr/share/php:/usr/share/pear:/usr/share/php') in /home/********/domains/*********/public_html/other/test.php:4

It all works except when you specify a successful page
I understand that your coding works as I have been using it for many years
I understand that the server works but they do not work together for some reason

The best Andrew
User avatar
Pablo
 
Posts: 23234
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Email form not working on new server

Post by Pablo »

I think you are looking at the wrong place. Version 5.5 specifies the minimum PHP version for PHP mailer!
All included versions are(6.8.0), so you should already have the latest versions.

The error log indicates that the files are not on the server or there is a configuration issue.
Please make sure you upload all files.
User avatar
BaconFries
 
 
Posts: 5871
Joined: Thu Aug 16, 2007 7:32 pm

Re: Email form not working on new server

Post by BaconFries »

For php mail to work you are required to use php 5.6 or higher. Why are you still using php 5.5 when your host supports 8.0 or higher. As you are using WB17 which supports php 8.x I would recommend you set the form to use this. You mention that the success page doesn't work what page extension is it set to .html or .php? Note the success page should not contain any php code within it as php needs to be processed on the server for it to work again I suggest you set to just . html
Please see the following on PHP version.compatibility
User avatar
wwonderfull
 
 
Posts: 1558
Joined: Fri Aug 21, 2020 8:27 am
Contact:

Re: Email form not working on new server

Post by wwonderfull »

AndySwiny wrote: Tue Aug 01, 2023 7:45 am The problem now is that if you set a successful page it does not work
On further reading there is an update for these files can you supply the updates for these files as it states that 5.5 does not work with version 8 PHP
Thanks Andy
Hostinger user here :) Yes there is a success page issue with higher php version in hostinger for some reason which has not been configured yet. I think I told about it many years ago but didn't need to use higher versions of php but yes as you said success page doesn't work it is true. On my case what happened with higher php versions is that the email comes successfully, but the database did not get the data and the success page did not show.

In HOSTINGER WEB SERVER The form works fine on php 7.3 - 7.4 but when it is set to php 8 or more like php 8.2 it makes the Success Page become empty it will pop up but wont show content styles or even variables just an empty page. I tested it myself. I think @crispy also uses hostinger maybe he knows something too about this.
User avatar
wwonderfull
 
 
Posts: 1558
Joined: Fri Aug 21, 2020 8:27 am
Contact:

Re: Email form not working on new server

Post by wwonderfull »

And also if you want to show php error logs in your hostinger webserver more easily then do this easy way full tutorial here

got to htaccess and paste these codes:

Code: Select all

php_flag log_errors on
php_value error_reporting 32767
php_value error_log "error_log.txt"
then just save the codes inside .htaccess

After that go to public_html directory create a file named error_log.txt and go to PHP Configuration and then go to php options and just checkmark displayErrors and LogErrors and at the bottom of the page there is a save button dont forget to click that.

so when you submit the form and error comes just go to that error_log.txt inside everything will show in detail.
User avatar
wwonderfull
 
 
Posts: 1558
Joined: Fri Aug 21, 2020 8:27 am
Contact:

Re: Email form not working on new server

Post by wwonderfull »

I did a test and this is what my php error log shows on hostinger with php version 8.2

[01-Aug-2023 ] PHP Warning: Undefined variable $upload_FieldName in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 ] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/domains/mywebsite.com/public_html/index.php:229
Stack trace:
#0 {main}
thrown in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 ] PHP Warning: Undefined variable $upload_FieldName in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 ] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/domains/mywebsite.com/public_html/index.php:229
Stack trace:
#0 {main}
thrown in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 13:53:47 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Duplicate column name 'FORMID' in /home/domains/mywebsite.com/public_html/index.php:242
Stack trace:
#0 /home/domains/mywebsite.com/public_html/index.php(242): mysqli_query()
#1 {main}
thrown in /home/domains/mywebsite.com/public_html/index.php on line 242


and below is the code which it was referring to which I think is the php script for the form.

$mail->CharSet = 'UTF-8';
$mail->WordWrap = 80;
$mail->Body = $message;
$mail->Send();
$search = array("ä", "Ä", "ö", "Ö", "ü", "Ü", "ß", "!", "§", "$", "%", "&", "/", "\x00", "^", "°", "\x1a", "-", "\"", " ", "\\", "\0", "\x0B", "\t", "\n", "\r", "(", ")", "=", "?", "`", "*", "'", ":", ";", ">", "<", "{", "}", "[", "]", "~", "²", "³", "~", "µ", "@", "|", "<", "+", "#", ".", "´", "+", ",");
$replace = array("ae", "Ae", "oe", "Oe", "ue", "Ue", "ss");
foreach($_POST as $name=>$value)
{
$name = str_replace($search, $replace, $name);
$name = strtoupper($name);
if (is_array($value))
{
$form_data[$name] = implode(",", $value);
}
else
{
$form_data[$name] = $value;
}
}
#229 for ($i = 0; $i < count($upload_FieldName); $i++)
{
$name = str_replace($search, $replace, $upload_FieldName[$i]);
$name = strtoupper($name);
$form_data[$name] = $upload_URL[$i];
}
$db = mysqli_connect($mysql_server, $mysql_username, $mysql_password) or die('Failed to connect to database server!<br>'.mysqli_error($db));
mysqli_set_charset($db, 'utf8');
mysqli_query($db, "CREATE DATABASE IF NOT EXISTS $mysql_database");
mysqli_select_db($db, $mysql_database) or die('Failed to select database<br>'.mysqli_error($db));
mysqli_query($db, "CREATE TABLE IF NOT EXISTS $mysql_table (ID int(9) NOT NULL auto_increment, `DATESTAMP` DATE, `TIME` VARCHAR(8), `IP` VARCHAR(15), `BROWSER` TINYTEXT, PRIMARY KEY (id))");
foreach($form_data as $name=>$value)
{
#242 mysqli_query($db ,"ALTER TABLE $mysql_table ADD $name VARCHAR(255)");
}
mysqli_query($db, "INSERT INTO $mysql_table (`DATESTAMP`, `TIME`, `IP`, `BROWSER`)
VALUES ('".date("Y-m-d")."',
'".date("G:i:s")."',
'".$_SERVER['REMOTE_ADDR']."',
'".$_SERVER['HTTP_USER_AGENT']."')")or die('Failed to insert data into table!<br>'.mysqli_error($db));
$id = mysqli_insert_id($db);
foreach($form_data as $name=>$value)
{
mysqli_query($db, "UPDATE $mysql_table SET $name='".mysqli_real_escape_string($db, $value)."' WHERE ID=$id") or die('Failed to update table!<br>'.mysqli_error($db));
}
mysqli_close($db);
$successcode = file_get_contents($success_url);
$successcode = ReplaceVariables($successcode);
echo $successcode;
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>
Last edited by wwonderfull on Wed Aug 02, 2023 10:23 am, edited 2 times in total.
User avatar
Pablo
 
Posts: 23234
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Email form not working on new server

Post by Pablo »

@wwonderfull
Thanks for trying to help. However, this is has nothing to do with sending emails.
This is because you have enabled 'upload files to a folder on the server'.

To test this correctly, please disable all advanced options in the form and only configure it to send emails. Otherwise your feedback may only cause further confusion...
User avatar
wwonderfull
 
 
Posts: 1558
Joined: Fri Aug 21, 2020 8:27 am
Contact:

Re: Email form not working on new server

Post by wwonderfull »

Pablo wrote: Tue Aug 01, 2023 2:29 pm @wwonderfull
Thanks for trying to help. However, this is has nothing to do with sending emails.
This is because you have enabled 'upload files to a folder on the server'.

To test this correctly, please disable all advanced options in the form and only configure it to send emails. Otherwise your feedback may only cause further confusion...
PHP version 8.2 Hostinger
The form works fine only when the form's advanced options are all turned off like mysql settings specially. The success page shows too. I even used attachments which also came in email without any error.

Only when I turned on the mysql option in the forms advanced option it showed this error.
Fatal error: Uncaught mysqli_sql_exception: Duplicate column name 'FORMID'

PHP 7.3 and 7.4 everything works fine in hostinger but only when it is above 8 those errors happen.
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

Thank you for all your replys.
It is nice to know someone else has experienced these problems. I think you are right it is PHP8 and above that causes the error with the successful page showing.

I will continue to investigate this and when I have found the solution I will come back and share. Thank you for all your help
All the best Andrew
User avatar
Pablo
 
Posts: 23234
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Email form not working on new server

Post by Pablo »

@AndySwiny

Please note that error shown in wwonderfull's test may not apply to you because he's using a different form configuration
I do not think these error are related. Also, as you can read the basic form works correct. So, it can also work for you.

First, make sure that you upload all files. The files that are include with WWB18 are the latest! See my previous replies.
Then check the PHP error log for other error (if any).

@wwonderfull
Please focus on the main issue. You may make it more confusing for Andy. These database errors are unrelated. There is most likely an error in your configuration. If you need help with this then open a new topic.
AndySwiny
 
 
Posts: 8
Joined: Mon Jul 31, 2023 7:03 am

Re: Email form not working on new server

Post by AndySwiny »

I now have my forms/emails working

Hi if you are having problems this is where to start and how to try and solve it

Start with three new pages
one page extension PHP
2 pages with HTML

Make sure you name each page correctly go to the advanced tab and set
jquery version 3.6.9 min.js
PHP version PHP5 - PHP8
Everything else remains the same default

For this I will name my pages

My form the PHP page
sent-ok HTML
not-sent HTML

on the PHP page put from on here you can use the wizard or not
go to form settings this is what I used

Name the form whatever you wish
Accept charset = ISO-8859-1
Target _top
Tick the box use built-in PHP
Put your Email in
set successful page to sent_ok HTML
set error page to not_sent HTML

Go to the advanced tab on their go to mail engine tab
Tick the box and set mail engine = ( Sendmail) everything else default

For now on your successful page just put a bit of text sent okay
on the error page just part not sent

now load all three files when you upload the PHP file it will upload three other files as well
Exception.php
PHPMailer.php
SMTP.php

Make sure these files are in the same directory as the form

Now go to the website fill in the form and see if it works this worked for me I hope it works for you

All the best Andrew
lummis
 
 
Posts: 222
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Re: Email form not working on new server

Post by lummis »

Andrew

Just a note of thanks as I have been having similar problems with Hostinger and had no success in resolving with their chat support. With my previous host I used SMTP successfully but on transferring to Hostinger 3 weeks ago, the emails generated via a form had been erratic. Your simple solution of using "sendmail" has worked for me, so I am very grateful. Now all I have to do is to sort out why MySQL scripts are not performing as they used to!

Brian
User avatar
wwonderfull
 
 
Posts: 1558
Joined: Fri Aug 21, 2020 8:27 am
Contact:

Re: Email form not working on new server

Post by wwonderfull »

Just in case if anyone wanted to know about the form not working on higher php versions. The problem I stated has been fixed and solved in the latest update 18.3.2.
Post Reply