I set up a contact form on my site using PHPMailer but it doesn’t work due to the mail() function being disabled on InfinityFree. So I configured it to use SMTP but it still isn’t working even when I provide my username and password. I need the contact form to send to my gmail address, no other email, so this should be straight forward.
I am aware of the following link but the link provided in the following page to create an App Specific Password doesn’t work:
Is there a more straight forward way of doing this? Am I allowed to use mail() to send to my own on-file address?
Hey there. I am having some issues with is contact form as well. Can you please provide your .htaccess file and domain?
No, that function is disabled.
Go you your google account (myaccount.google.com) and go to Security → App Passwords. Note that you must turn on 2FA (2-Factor-Authorization) first. You can then create an app passwords selecting “Mail” and “Custom Name” from the dropdown menus on the bottom. Copy the displayed code, but do not click “ok” or “close” or whatever it says. (Once you confirm it is working, you can close the pop-up with the password. Once you close it, you cannot view the password again, you would have to create a new one)
I enabled two-factor authentication and that worked. The problem is what if I want to disable two-factor authentication? Which I may want to do at some point.
I think that infinity free should come up with a better solution for a contact form than to have to jump through all of these technical hoops.
Well, than the contact form would stop working. You can always create a new Gmail account just for the form, and set up a filter in that new Gmail account to send all incoming mail to your other account. 2FA is recommended to be on anyway.
Like what? SMTP is the only other way to do it, and keeping a username and password in plain text is always a bad idea. If you have other ideas, feel free to share! (Oh, you don’t have to use our form, you can use third party forms as well)
Oh there could be a ton more! Try setting up some of the things I hassle with this will seam super easy and simplistic. The main this with this is that it is super simple, few things are required, and few things need to be configured, and you can get it setup fairly quickly. The more you do these things, the faster (but more annoying) they get.
We do not provide PHP mail() ourselves, but you are free to use any other SMTP service you want. That’s as simple as we can make it.
Most of the hoops you just jumped through are related to getting your SMTP library to work and setting up the right credentials in Gmail. Neither of which are things we can make easier.