January 22, 2018 at 1:06 pm #5007
When you have set up your web you need a way of your clients getting back to you ; in the old days web sites had links like get back to me.
There are a few issues with this:
firstly clicking on the link can launch a pop up on your own computer to configure your email client, if its not set up. It won’t be set up if you for instance you normally go straight to mail.google.com via your browser to get your emails.For these people having a configure your email client wizard popping up is ging to be an irritation.
The other thing is that leaving an email address exposed on a web leaves it open to be crawled by a bot leading to a mass of spam emails.
The answer then is not to have an exposed email address but instead have a page where prospective clients filling a couple of text boxes & then you get back to them. The contact form can be done in html that does a POST to a php page to process. In essence on the processing php page you collect the submitted form data using $_POST[‘nameoftextbox’]; you set it up so that the data gets sent to your own email address ; but how? basically there are two choices the classic inbuilt php function mail($to,$subject,message); or through a dedicated SMTP . mail() works is simple and might be acceptable but can be flacky. On a live web you normally use your own domain name like smtp.somedomain.co.uk or sometimes your hosting account domain. But i think we are jumping the gun because its probably not a good idea to do anything live until you have tested it on your own PC. Here the best way so as not to upset anyone is just to use google SMTP & get access to it using your own personal gmail credentials. Recently I was in this position that I needed to test out a contact form on xampp .I did use my google mail credentials but since i didn’t like the idea of doing settings “click for less secure apps…” anyway for my own gmail I have a two step process set up. the answer was to log into google and go to generate app passoword. here you don’t use your normal gmail password but create a generated one and use that. To cut a long story short I got SMTP working from a web in /opt/lampp/htdocs (xampp) using my own personal gmail account name and a generated password. For the functionality i used PHPMailer on github. The guys that create these sort of libraries are very clever ,but like a lot of nerds they tell you everything excpet how to do it simple and just mail text from a contact form. To help you going thrugh the same learning curve I adpated my code to a simple porject containing the PHPmailer & sent it to mateus at freehosting. Basically if you unpack it in xampp and tweak a couple of settings you should be good to go.Just ask Mateus for the zip file i sent him!
The only other thing to add is that i didn’t do any scrub cleaning of submitted user or security ,so that up to you to do.
You must be logged in to reply to this topic.