Skip to main content
Inspiring
March 26, 2019
Answered

Looking for Email Form script recommendations for PHP / Desktop+Mobile (with or without jQuery enhancements)

  • March 26, 2019
  • 1 reply
  • 1579 views

I've been working on my first website in years (following a self-imposed break from online dev) and had a lot of catching up to do. Before the break, designing for mobile was a secondary concern. Sites were a lot more static. Bootstrap wasn't widely-used, but jQuery was. And CSS animations weren't as casual a thing as they are today.

That being said, I'm glad to say that with the help of the superheroes in this sub (some of whom have been selflessly helping ordinary citizens since the Macromedia Usenet days) I've caught up to the important stuff, and am now at the final stage of the site's development : the contact form.

For context, all my pages are PHP (I like using PHP includes to assemble the head+body+foot) and I'm already linking to jQuery for my lightbox (so it can be jQuery-dependent if required). And NancyO reminded me a while back that the form needs to be mobile-responsive as well.

So what I'm looking for, then, would be a PHP-based, mobile-friendly script that may or may not also use jQuery enhancements (especially if I can control them). I feel like there are thousands of free form scripts out there and it's not always clear what they're built for (the language is sometimes a little over my head).

My needs could not be more basic : "Want to drop me an email? Here's a form."

Do you guys have a favorite to recommend in 2019?

(After this, I think I'm done!)

This topic has been closed for replies.
Correct answer osgood_

osgood_  wrote

Yes, that's the one.

Not to seem ungrateful (because not even Dreamhost wants to waste their time on this one with me, as "this goes a little beyond the scope of support we provide") but I'm finding it difficult to stay focused on this thing's pace; which is probably why I tend to avoid video tutorials in general. Is there a text version of it somewhere with code I can just copy/paste, test-drive and deconstruct?

Going back to Nancy OShea​'s suggestion, is this what I need to be looking at if all I'm looking to do is set up a simple HTML contact form that'll send me an email on form submit, and know how to handle simple errors like mandatory fields?


https://forums.adobe.com/people/Under+S.  wrote

osgood_   wrote

Yes, that's the one.

Not to seem ungrateful (because not even Dreamhost wants to waste their time on this one with me, as "this goes a little beyond the scope of support we provide") but I'm finding it difficult to stay focused on this thing's pace; which is probably why I tend to avoid video tutorials in general. Is there a text version of it somewhere with code I can just copy/paste, test-drive and deconstruct?

Under the video there is a 'show more' link. If you cick on that there is a download link to the code.

https://forums.adobe.com/people/Under+S.  wrote

Going back to https://forums.adobe.com/people/Nancy+OShea 's suggestion, is this what I need to be looking at if all I'm looking to do is set up a simple HTML contact form that'll send me an email on form submit, and know how to handle simple errors like mandatory fields?

No. That shows an example of deploying PHPMailer using 'Composer',  a workflow where you would be using the terminal to set up the PHPMailer script but first you have to install 'Composer' on your machine....too much trouble in my opinion unless you're a nerdy type.  If you are going to use PHPMailer I suggest you download the zip file to which Nancy supplied a link to in post No. 3. However you still have work to do because PHPMailer alone contains no form validation apart from exiting the script if a non-valid email is supplied, which means the user gets delivered a blank page instead of a message saying the email is invalid. You need to code the validation of the form fields prior to handing the information being collected off to the PHPMailer script. Of course you can use the script without any validation but you risk getting spam.

The youtube video I posted a link to, which uses the php mail() function instead, includes validation of the email field and some sanitisation of the form fields to stop undesired characters being injected into the form fields. Of course html5 has its own email validation <input type="email"> which wont let the form be submitted unless a valid email is supplied, so you could use that if you only wanted to validate the email form field.

When I say valid email I mean any email that's formatted like an email, the email doesnt have to exist so its no protection against spam, you will more than likely need to introduce a form captcha or a question/answer form field BUT I would for now just concentrate on getting the basic form up and running as they can be introduced later.

1 reply

Nancy OShea
Adobe Expert
March 26, 2019

PHP Mailer from Github is the one everyone uses these days.   It's safe, secure and works with or without a PHP mail server.  

GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP

Nancy O'Shea— Product User, Community Expert &amp; Moderator
Brainiac
March 26, 2019

https://forums.adobe.com/people/Nancy+OShea  wrote

PHP Mailer from Github is the one everyone uses these days.   It's safe, secure and works with or without a PHP mail server.  

GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP

Always seemed a bit of a nightmare to set up to me, so I never pursued it, opting for the easier to set up php mail() function assuming the host has that function set to on, all my hosts do.

Presumably you still have to set up the validation of the form fields yourself before you hand the information off to the phpMailer script?

The actual example code at the GitHub page is once again poor as it doesnt address how to get information out of the form but just hard code some crap information, which I'm sure is pretty useless to anyone. I have zero idea why they show such bad examples as default.

Also not many want to use composer to get the f•••ing scripts onto their computer - they hide away the most helpful option (to download the zip file) in the text. What idiot writes this boll*cks.
Nancy OShea
Adobe Expert
March 26, 2019

PHp Mailer is not just some simple copy & paste script.  It's an actual PHP sending library. capable of handling almost any scenario.  

The Zip file download

https://github.com/PHPMailer/PHPMailer/archive/master.zip

To see what all you can do, open the  Examples folder.

osgood_  wrote

Always seemed a bit of a nightmare to set up to me, so I never pursued it, opting for the easier to set up php mail() function assuming the host has that function set to on, all my hosts do.

Unfortunately,  PHP Mail () function has gone out of favor.  Most hosts discourage its use.  They frequently recommend PHP Mailer though because it's very flexible.

Nancy O'Shea— Product User, Community Expert &amp; Moderator