Solved

PHP mailer form on Windows server

Posted on 2009-04-14
2
569 Views
Last Modified: 2013-12-13
Hello

I have a website hosted on a Windows server. I need to get the contact form working, but I believe the code is missing the authentication parts, just not sure what I'm missing. Can someone help me out with that?

The current code I have is below:
<?php
// list all vars to be expected from the movie
$vars = array("contact_name", "contact_email", "contact_message");
// and import them into the script
foreach($vars as $var)
	if(isset($_POST[$var]))
		$$var = $_POST[$var];
	else
		$$var = '';
 
// where to send it
// remove or configure one of the two code blocks
// otherwise your mail will be sent to johnnybegood@hotmail.com :)
 
// ***** or one fixed recipient ******
$recip = "info@mydomain.info";
//****  end fixed recipient *******
 
$headers  = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=utf-8\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: photographer@domain.com";
 
// build up message
// this code for any multiline text fields
$message = str_replace("\r", "\n", $contact_message);
// info vars
$sender = $_SERVER[REMOTE_ADDR];
// you can rearrange this - just do not add or remove quotes
$mailbody = "Contact form send by:
Name: $contact_name
Email: $contact_email
 
Message:
$contact_message
-------
sender's ip: $sender";
 
mail($recip, "Contact form", $mailbody, $headers);
 
// and tell visitor
print "&status=sent_ok";
?>

Open in new window

0
Comment
Question by:Trevor Local
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:Trevor Local
ID: 24143325
I'm actually switching to Linux server, so we'll see if that works!
0
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 500 total points
ID: 24144194
If you do need to do it on windows http://www.matthewstevenkelly.com/blog/kb/php/php-email.html

The best approach is to use a 3rd party mail program. In the past I have used PHPMailer as it is has all features I have needed. This script is the fix to many SMTP email problems in PHP!

It additionally allows for SMTP authentication where required.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question