Page 1 of 1

Host solution for emails needs php code

Posted: Mon Jan 30, 2023 5:42 pm
by redbush
Script URL:
Version of script: 1.9.0
Hosting company: one.com
URL of phpinfo.php:
URL of session_test.php: https://tanbur.co.uk/gbook/gbook.php
What terms did you try when SEARCHING for a solution: have searched many with email problems

Write your message below:
I am not receiving email notifications. The php settings script has my email correct. So I contacted the hosting company today through their chat. I've been given a line of

"......this PHP mail() code should work:
https://one-docs.com/tools/pastebin/NlVP3ite
Of course, setting a domain-specific address with the default placeholder."

So I had a go at putting this into settings,php; but still no emails. I guess my coding skills are not up to the task, so any advice would be appreciated.
And I'll have another go using that from their pastebin.

Re: Host solution for emails needs php code

Posted: Mon Jan 30, 2023 6:46 pm
by Klemen
Not sure if the person on the chat understood what you were trying to say as having "https" in the PHP mail() code doesn't really make sense.

Try this:
1. copy this code:

Code: Select all

<?php
error_reporting(E_ALL);
mail('you@example.com', 'Test', 'Test message');
echo 'Email sent';
?>
2. change you@exmaple.com to your email address
3. save it as "email-test.php"
4. upload to your server
5. run email-test.php in your browser

Do you receive the test email?

If no, check with your host why this simple PHP mail code does not work on their server.

Re: Host solution for emails needs php code

Posted: Tue Jan 31, 2023 2:22 pm
by redbush
Many thanks for getting back to me.
The email-test.php page view said 'email sent' but the email did not arrive.
So the chat person at one.com said I need to check as follows:

"Please note that the "To" or "From" address must be an active email account on your domain with one.com..... To ensure that your contact form is properly setup, please follow this guide:

https://help.one.com/hc/en-us/articles/115005594345-Can-I-send-emails-from-my-website-
...."

I have 2 active email accounts on the domain, but neither received anything when tested.
The above link takes me to
https://www.php.net/manual/en/function.mail.php
so I'll have another read there.

Re: Host solution for emails needs php code

Posted: Tue Jan 31, 2023 10:39 pm
by Klemen
I'm not familiar with one.com but getting that sample email script I gave you is something they need to help you with.

Once that works, we can get GBook to send emails too.

Re: Host solution for emails needs php code

Posted: Wed Feb 01, 2023 11:36 am
by redbush
One.com are looking into the coding of test email and will get back to me.

Re: Host solution for emails needs php code

Posted: Thu Feb 02, 2023 4:11 pm
by redbush
Response from host was not successful. While waiting for their second response, I've found a solution. Yay!!!
<?php
$to_email = 'someone@yahoo.co.uk';
$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail function';
$headers = 'From: someone@hostserver.co.uk';
$from_email = 'someone@hostserver.co.uk';
mail($to_email,$subject,$message,$headers,$from_email);
?>

Mail was received!!!

Re: Host solution for emails needs php code

Posted: Fri Feb 03, 2023 12:55 am
by Klemen
Great.

Now you can edit your gbook.php to do something similar.

Find this code twice in gbook.php:

Code: Select all

mail($settings['admin_email'],$lang['t41'],$message,"Content-type: text/plain; charset=".$lang['enc']);
Change it to something like (I didn't test):

Code: Select all

mail($settings['admin_email'],$lang['t41'],$message,"From: someone@hostserver.co.uk\nContent-type: text/plain; charset=".$lang['enc']);

Re: Host solution for emails needs php code

Posted: Fri Feb 03, 2023 12:04 pm
by redbush
Thanks for amended code.
Your 2022 version is not sending, but I can't find the fault.
However, I found an intact guestbook from 2009, version 1.7.0. The message title is received but the comment is blank.

Re: Host solution for emails needs php code

Posted: Fri Feb 03, 2023 11:16 pm
by redbush
Something weird happens with the host server. The 2022/23 version that failed to send any messages from guestbook now also fails to send the test email that was successful yesterday. If I go the file, make a small edit it sends. So I'll check with host about this anomaly.

Re: Host solution for emails needs php code

Posted: Sat Feb 04, 2023 12:01 am
by redbush
Same thing with 2023 gbook. Edit and save. It then sends.

Re: Host solution for emails needs php code

Posted: Sat Feb 04, 2023 12:30 am
by Klemen
Not sure what is going on exactly, but as long as it sends you're good to go :)

Re: Host solution for emails needs php code

Posted: Wed Feb 08, 2023 10:21 pm
by redbush
Everything is working well! I've edited the guestbook to create 'comment boxes' for most pages of Tanbur Music Education Links. Here are a couple of examples: http://tanbur.co.uk/banyan.html
http://tanbur.co.uk/hatdance.html