At the behest of a client, I just updated my old Form Emailer script. I wrote the script donkey’s years ago, prior to developing Form Tools. In essence it offers a subset of Form Tools’ functionality: the ability to email the contents of a web form to a person or persons. Nothing special: just a standard PHP form emailer in the tradition of sendmail, etc.
Version 1.1 offers the rather significant improvement of being ability to define your own email templates. You create a text file containing the contents of your email, and then pass along its location in your form. When the form is submitted it will send the contents of that file. The really handy thing is that it allows you to define placeholders like %myfield%. When the form is submitted, those placeholders are converted to the corresponding form field value.
I also added an option to send a receipt email to the person submitting the form. This is powered by the same email template functionality.
Hope it helps!
I tried your form mailer which works great except that the cc and bcc options do not seem to be working. I used the exact code per your example and put it directly after the recipient line. Any ideas or common mistakes you can think of? Thanks again for offerign the code. Very nice.
Hey Kyle,
Hmm… try this: on line 129 of email.php, change:
$header .= “Cc: ” . $_POST['cc'];
to:
$header .= “CC: ” . $_POST['cc'];
I’ve read that it may be case sensitive on some systems. Let me know if this works!
Hello!
Your form mailer is outstanding, but I have a question regarding the variables. I’m trying to use this in my form: where %email% is the users e-mail from the e-mail field of the contact form.
This is okay. It is sending e-mail, but when I hit reply from Outlook express, on an e-mail recieved from my website, the reply e-mail field it has written %email% and not the e-mail of the person.
How can I fix this?
Cheers, and keep up the good work.
Hi Gergely,
Fixed! Sorry, there was no placeholder replacement on the “email_from” form field, so it wasn’t working properly. Just overwrite your email.php file from the downloadable zipfile. Should work without a hitch then!
All the best –
Ben
Hello Ben!
I looked at what you’ve fixed. unfortunately the problem wasn’t the email_from field, it was the REPLY_TO field. This is still not fixed.
Thanks in advice!
Gergely
Doh! Sorry Gergely, all fixed. :-)
This form mailer was just the thing that I was hunting for as a starting point for a submission form for a newsletter for my local bowling association. I am still trying to play catch up on all the different programming languages since I graduated from a local college in 2003 where Computers and Web Design were my majors but at that time all they taught in the Web Design arena was Flash, Html and Java Scripting so PHP, XML and XHTML, ect are still a bit new to me since I got away from things due to personal reasons. Anyway, I began with your form, modified it to fit what I needed and made the changes in the email.php file. I have PHP 5.XX on my machine for testing. I have all the files in one folder on my machine which should allow everything to work, however when I fill in the form fields and hit the submit (send email) button the only thing it does is open the email.php file. Am I missing something? I need to test this on my machine before sending the files to the person that is handling the website. I almost know that this is staring me right in the face. lol Any help would be appreciated, thanks in advance.
Hi Darrell,
Ah – it sounds like maybe your server doesn’t run PHP or doesn’t understand the .php extension (which is unlikely, since it’s pretty standard). Often you’ll find that if a page pops open to be downloaded, the server hasn’t properly interpreted it and converted the PHP (or Perl, ASP, JSP or whatever) to HTML. Try this: create a file on your server called phpinfo.php and add this to it:
< ?=phpinfo()?>
Then load it up in your browser. If PHP is working you should see the details about your PHP configuration. If it isn’t, I’m afraid you’ll need to contact your hosting provider and ask them about it.
Sorry I couldn’t be more help!
- Ben
Ben
Thanks for the advice. I also think that the problem is in the PHP installation. I tried the PHP installation for Windows XP and set it up with the proper web server attributes in the installation and still the same issue. So I think it is with the installation. I have an extra machine and am going to set that one up specifically as a web server and install PHP on it and see what happens. Thanks again for the advice and if I have any other questions I will post them.
Darrell
Can the form mailer software be combined with the PHP validation software so as to send an email after the fields are validated? If so, are there instructions someplace for that?
Thanks.
Hi Ben,
Thank you for letting us use your snippets of code – much appreciated!
I am using the form mailer for a client of mine who would like their form emails to display as a message of ‘high importance’.
If you have any ideas or suggestions I would be very grateful.
Rachel
I seem to have found the answer to my own problem.
I added
$header .= “X-Priority: 1\n”;
$header .= “X-MSMail-Priority: High\n”;
to the end of the ‘// build our email header’ code – it seems to work.
:-) I am a happy camper.
Rachel
Hello Ben. thanks for this awesome and easy to understand script. I’ve got everything working fine but have one question. Is there a way to send the email based on the value of menu type drop down value? I want the email to be sent to whomever the sender picks from in the drop down menu. I did some research online but still lost. I believe i need to setup a switch function to handle that but don’t know where it would go. Anything would be helpful.
Hello Ben!
Still using your form e-mailer and saw that you’ve made some upgrades.
I wanted to use the receipt_email_field function, but I encountered a problem:
This is how my form hidden fields look like and it gives me some messy e-mail after I submit the form:
I have a problem because:
1. the %emailFrom% field doens’t get replaced with the users’s e-mail from the submitted form.
2. the recieved e-mail looks like this, but the RECEIPT EMAIL ADDRESS doesn’t get a copy:
receipt email field: %emailForm%
receipt email subject: Your submission
receipt template: receipt_email_tpl.html
email html template: email_tpl.html
nameForm: Tester George
emailForm: [email protected]
msg1ContactForm: qasdasr ssysf hdgj fghnfgh
signatureForm: Anonymous
Any help would be much appreciated.
Thanks,
Gergely
I think my included form example is not allowed in comments. :|
Ah and one other thing:
If I try to send multiple BCC’s it sends them but the TO: field in the e-mail is showing the first BCC’s email address.
Thanks,
G.