Guide to receive data from webform in an e-mail

Hi,
My website has a form and i would like to receive the information filled in the form by prospective client. I believe e-mail would be the right way to receive such information. I dont mind if i get the info on my gmail or webmail created in inifinityfree.

I tried to follow the instructions mentioned on https://infinityfree.net/support/how-to-send-email-with-gmail-smtp and had following questions.
Q1) Do i have to still follow the guide on the link i just share in case i am ok to receive mails on infinityfree webmail
Q2) The extracted folder has multiple folders and file. How should i upload them in htdocs? should i upload each and every file in the extrated folder or can i just upload the ZIP file of the PHPmailer(extrated folder)
Q3) What should be the filename of the PHPmailer script that i upload in htdocs?
Q4) Why am i getting login fail error when i am trying to login to infinity free webmail? i have checked and the mail account name and the passwords i am entering is for sure correct.

Regards
Tejesh

Regards
Tejesh

Thank you for your questions, I’m going to go through them one by one.

@Tejesh said:
Q1) Do i have to still follow the guide on the link i just share in case i am ok to receive mails on infinityfree webmail

There is no exception for receiving email on mailboxes on InfinityFree. The email filters affect all addresses and destinations.

@Tejesh said:
Q2) The extracted folder has multiple folders and file. How should i upload them in htdocs? should i upload each and every file in the extrated folder or can i just upload the ZIP file of the PHPmailer(extrated folder)

To use PHPmailer, you need all the files present in the zip file. The easiest way to manage the files is to upload all the contents of the zip file into a folder named phpmailer. But it’s up to you, as long as the directory structure inside the zip file is still in tact.

Whether you want to extract the zip file on your desktop or use a file manage to extract or upload it is entirely up to you. Whatever is more convenient for you.

@Tejesh said:
Q3) What should be the filename of the PHPmailer script that i upload in htdocs?

You can call the script whatever you want. Call it contact.php, sendmail.php, submit.php or whatever else. As long as it has the .php extension and you can use the URL, you’re good to go.

Q4) Why am i getting login fail error when i am trying to login to infinity free webmail? i have checked and the mail account name and the passwords i am entering is for sure correct.

Please make sure you are using the email address and the password of the email account you’re trying to access. You cannot login to webmail with your hosting account username and password.

Hi,
Thank you for your response. I am facing further challenges.

I am getting HTTP error 500 (the page isnt working) when i submit the form.
My web form calls ‘send_mail.php’ which is the PHPmailer script i created. The code i used is

you would have access to my account. Could you please check and let me know where am i going wrong. It is a very simple form and email test

Also, i have completed other actions like
uploading PHPmailer files
enabling less secure apps access on gmail
setting MX record

A HTTP Error 500 means your script is crashing. Please see this article for info on how to find the actual error message.

Thanks for the instructions, I found this error


Warning: require(./PHPMailer/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/vol13_1/epizy.com/epiz_21690680/htdocs/send_mail.php on line 6

Fatal error: require(): Failed opening required ‘./PHPMailer/PHPMailerAutoload.php’ (include_path=‘.:/usr/share/pear/’) in /home/vol13_1/epizy.com/epiz_21690680/htdocs/send_mail.php on line 6

Well i had mentioned this code on line 6 of my PHP script
require ‘./PHPMailer/PHPMailerAutoload.php’;

and the file ‘PHPMailerAutoload.php’ clearly exists in my account path htdocs/PHPMailer just as instructed in https://infinityfree.net/support/how-to-send-email-with-gmail-smtp/

Can you kindly check my account and inform if i have done something incorrectly

@Tejesh said:
Thanks for the instructions, I found this error


Warning: require(./PHPMailer/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/vol13_1/epizy.com/epiz_21690680/htdocs/send_mail.php on line 6

Fatal error: require(): Failed opening required ‘./PHPMailer/PHPMailerAutoload.php’ (include_path=‘.:/usr/share/pear/’) in /home/vol13_1/epizy.com/epiz_21690680/htdocs/send_mail.php on line 6

Well i had mentioned this code on line 6 of my PHP script
require ‘./PHPMailer/PHPMailerAutoload.php’;

and the file ‘PHPMailerAutoload.php’ clearly exists in my account path htdocs/PHPMailer just as instructed in https://infinityfree.net/support/how-to-send-email-with-gmail-smtp/

Can you kindly check my account and inform if i have done something incorrectly

I checked your account, and in the script you reference PHPMailer but the folder is called PHPmailer (note the capitalization of the M). If you update that, it should work.

Thanks. I corrected it but this time got another error

‘Mailer Error: SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

please help.

check whether you did all the actions (on google acc)
if it’s gmail https://infinityfree.net/support/how-to-send-email-with-gmail-smtp/

you can also turn on debugging

put this code above server settings (you will see * Server Configuration * comment in the example from the link )

// Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$ mail-> SMTPDebug = 2;

example

$mail = new PHPMailer;
$mail->isSMTP();

// PUT HERE DEBUG code OK ?

/*
 * Server Configuration
 */

Hi,

I tied emailing on my Gmail accounts and both times i got this error after placing the debug code

Parse error: syntax error, unexpected ‘mail’ (T_STRING), expecting variable (T_VARIABLE) or ‘{’ or ‘$’ in /home/vol13_1/epizy.com/epiz_21690680/htdocs/send_mail.php on line 15

I have taken the required actions on my g-mail account.i.e. 1. Two sets google verification is not turned on. Hence, the page says ‘the settings you are looking for are not available for your account’ when i try to set up APP password 2. Less Secure APPs access is ON

With this it does not look like a google issue.

I tried using infinity free webmail account and passoword in my ‘send_mail.php’ and i still go the same error pasted in this comment above.

Please help.

To avoid going back and forth on this issue, it would be great if you could fix the file. I am okay to receive mails on my infinity free ID as well. The ID and password are mentioned in the files in the htdocs in my one and only account

Regards,
Tejesh Neroy

I checked your script as well with the debug option (please note that @OxyDac 's code snippets contains a few extra spaces which will break the script).

In the SMTP log, I saw an error message saying that the login details were rejected. Please check whether you are using the right username and password, whether Insecure Apps are enabled for your account and SMTP access is enabled in Gmail.

@Admin

Trust, i have no action on the script and @OxyDac is helping. this was taken from infinityfree support forum for email

Yes, i might have used wrong login details sometime back which resulted in login rejection.

Can i use infinity free webmail login credentials with the code being the same? I believe i will have to change only following three lines. Let me know else i will revert to using gmail. Insecure Apps are definitely enabled for gmail. Do you explain on the SMTP access in gmail? how do i set that?
$mail->Username = “[email protected]”; // Your Gmail address.
$mail->Password = “Tejesh123$$”; // Your Gmail login password or App Specific Password.
$mail->addAddress(‘[email protected]’, ‘John Doe’); // Set the recipient of the message.

Regards
Tejesh

1 Like

SMTP access is not available for free hosting accounts, so no.

Also, it would a bit silly to nail down PHP mail but leave our own SMTP server unrestricted.

@Admin

I am bit confused with the last statement. I am understanding that e-mail would not be possible through infinityfree webmail account, please correct me if my understanding is wrong.

I can confirm that insecure APPs access is on for my gmail. in this case i am awaiting @OxyDac 's comment on the script

Regards,
Tejesh

when I go to your website and click on submit
you still have syntax error (my mistake)

so please edit send_mail.php
line 15 to $mail->SMTPDebug = 2;

if you do not need this debug code
put it in the comment // $mail->SMTPDebug = 2;

btw. Google limits the amount of mail a user can send via SMTP server.
Number of messages sent per day 100 emails.
Restriction is automatically removed within 24 hours after the limit was reached.

@Tejesh said:
@Admin

I am bit confused with the last statement. I am understanding that e-mail would not be possible through infinityfree webmail account, please correct me if my understanding is wrong.

You can send email through InfinityFree webmail. But you can only send it through webmail. You cannot connect to it from other software, including software hosted on your hosting account.

@Tejesh said:
I can confirm that insecure APPs access is on for my gmail. in this case i am awaiting @OxyDac 's comment on the script

Did you try to follow @OxyDac 's instruction on the debug output? I tried it and got a nice export of logs including a message say something like “Invalid credentials” along with a link to Google’s support center.