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
Community 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
Under S.Author
Inspiring
March 27, 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

Unfortunately, dropping me in front of a GitHub link is like dropping a child in front of a highway. I have no idea what to do next without installation notes.

EDIT: Is this the same "PHPMailer" you're referring me to? Dreamhost seems to offer it natively. And there appears to be instructions, although this PHP stuff is quite intimidating to even look at.

Under S.Author
Inspiring
March 27, 2019

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

EDIT: Is this the same "PHPMailer" you're referring me to? Dreamhost seems to offer it natively. And there appears to be instructions, although this PHP stuff is quite intimidating to even look at.

Yes, its the same phpMailer.

If you find it a bit daunting then find out if your host supports the php mail() function. There are plenty of decent tutorials on youtube that can guide you through setting up a simple feedback form using that, which might be a bit less overwhelming.

Usually things look more complex than they actually are, the poor documentation and examples provided are not helpful. You might do well to look up some youtube videos relating to using phpMailer if you choose that option.


osgood_  wrote

Yes, its the same phpMailer.

Rightly or wrongly, someone just told me both those tools (PHPmail + PHPmailer) are for SENDING emails en masse (as in, spamming the population) and not for use as a simple contact form on a website. Which might explain why my eyes got so wide looking at that PHP code.

Just so we're 100% clear, I'm simply looking to let people contact me via my website -- in other words, receive -- not send. They don't need to be able to attach files, format the text in any way (plain text is fine)... just basic 'contact me' stuff.

All it really needs to do better than the next tool is handle the usual eventualities (like missing fields or improper email address syntax) as elegantly as possible; ideally without page-refreshing.