• Home
  • Services
    • Web Design Updates
    • Website Development
    • eCommerce Web Design
    • Responsive Website Design
    • Multimedia Website Design
    • Search Engine Optimization
    • Website Maintenance Services
  • WebLog
    • Development
    • Search Engine Optimization
    • Coding
    • Operating Systems
    • Media
    • News
  • Webmaster Tools
    • CSS Button Generator
    • RGB and HEX Color Charts
    • Meta Tag Generator
    • Robots.txt Generator
    • Password Encryption
  • cPanel
    • cPanel Interface
    • cPanel Homepage
    • Add Domain Names
    • Email Accounts and Settings
    • cPanel File Manager
    • cPanel Databases
    • cPanel Stats and Metrics
  • Web Hosting
    • Basic Web Hosting
    • Standard Web Hosting
    • Premium Web Hosting
    • White Label Hosting
  • Computer Repair
Web Hosting Login
Login

Login
Central Montana Web Design - ReddWebDev
  • Home
  • Services
    • Web Design Updates
    • Website Development
    • eCommerce Web Design
    • Responsive Website Design
    • Multimedia Website Design
    • Search Engine Optimization
    • Website Maintenance Services
  • WebLog
    • Development
    • Search Engine Optimization
    • Coding
    • Operating Systems
    • Media
    • News
  • Webmaster Tools
    • CSS Button Generator
    • RGB and HEX Color Charts
    • Meta Tag Generator
    • Robots.txt Generator
    • Password Encryption
  • cPanel
    • cPanel Interface
    • cPanel Homepage
    • Add Domain Names
    • Email Accounts and Settings
    • cPanel File Manager
    • cPanel Databases
    • cPanel Stats and Metrics
  • Web Hosting
    • Basic Web Hosting
    • Standard Web Hosting
    • Premium Web Hosting
    • White Label Hosting
  • Computer Repair

PHP Send-Mail: The ultimate script

This simple PHP Mail Script might be for you:

Home CodingPHP Send-Mail: The ultimate script
The ultimate PHP Send-Mail script

PHP Send-Mail: The ultimate script

February 5, 2012 Posted by Alan Coding

PHP Send-Mail: The ultimate script. If you are tired of spam, or are confused about various security issues related to your cgi-mail or are frustrated with having to configure things like cgi email handlers written in perl, then this simple PHP Mail Script might be for you.

This mail script, written in PHP, is fast and light. It records the ip address of the one filling it out so that you can track who uses your form.

It also strips out malicious coding from any of the would-be script kiddies that are out there.

// Configuration Settings
$SendFrom = “YourBusiness.com “;
$SendTo = “You@example.com”;
$SubjectLine = “fill your subject line in here”;
$ThanksURL = “http://www.example.com/thankyou.htm”; //confirmation page
$Divider = “~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~”;

// Build Message Body from Web Form Input
$MsgBody = @gethostbyaddr($_SERVER[“REMOTE_ADDR”]) . “n$Dividern”;
foreach ($_POST as $Field=>$Value)
$MsgBody .= “$Field: $Valuen”;
$MsgBody .= “$Dividern” . $_SERVER[“HTTP_USER_AGENT”] . “n”;
$MsgBody = htmlspecialchars($MsgBody); //make content safe

// Send E-Mail and Direct Browser to Confirmation Page
$Spam = count($_POST) == 0 || stristr($MsgBody, “cc: “) ||
stristr($MsgBody, “href=”) || stristr($MsgBody, “[url”);
if (!$Spam)
mail($SendTo, $SubjectLine, $MsgBody, “From: $SendFrom”);
header(“Location: $ThanksURL”);
?>

Save the code above to a text editor and name it as contact.php. Next, you’ll want to fill in the configuration setting to reflect your own domain email, business and so on. You can also designate a thank you page that the script will send your visitor to once the send button has been clicked.

Configure your form like this;

form action=”contact.php” method=”post”

Upload your PHP contact.php to the directory/folder that your contact form page resides in, and you should be good to go.

This script will send mail to and from your domain .. you can’t use it to send mail to any other domain, and free email address configurations won’t work. The script logs the ip address of the one that uses your form, so that it will be easier for you to determine whether or not the person using it needs to be blocked via their ip address in your .htaccess file.

You can build any kind of form, from surveys to job applications and this script will work on all of them .. it’s handy, simple, and very fast.



Tags: cgi-mailcodinginternetInternet Web Developmentjob applicationsmailmail scriptperlPHPsurveys
Share
0

About Alan

Changing the world, one lonely line of code at a time -- Specializing in projects that combine beautiful interactive design with intelligent technology.

You also might be interested in

Responsive Web Design with Laura Kalbag

Responsive Web Design with Laura Kalbag

Aug 12, 2015

Responsive Web Design with Laura Kalbag: A talk by Laura[...]

How to build a Linux Web Server with an old computer

How to build a Linux Web Server with an old computer

Sep 17, 2015

Interested in learning about Linux or running your own Linux[...]

Computer Graphics and Graphics Devices

Computer Graphics and Graphics Devices

Sep 17, 2015

Computer graphics – are graphics created using computers and, more[...]




video
play-sharp-fill
Link

New England Journal of Medicine

Categories

  • Coding
  • Development
  • Media
  • News
  • Operating Systems
  • Search Engine Optimization

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Send Message
Experience the freedom of the Internet with your own Website Solution. Get Your Free Quote!


- internet web hosting
- linux server
- domain names
- dedicated ip's
- shared web hosting
- dedicated web hosting

Website Development

- forms and email
- jQuery sliders
- photo galleries
- image graphics rendering
- sitemaps xml
- social network integration
- website maintenance

Website Design

- website design
- website redesign
- website development
- ecommerce websites
- content management systems
- website rescue
- small business web design

Contacts

Great Falls, MT 59404
Phone: 406-788-4084
Friday - Sunday
8 AM – 8 PM MST

2025 © ReddWebDev.com

  • Contact
  • About
  • Acceptable Use Policy
  • Privacy
  • Linux for PC’s
Prev Next