PHP Email Handler Need to Add SMTP Authentic, Need Help!!

3 replies
  • WEB DESIGN
  • |
Hi,

I've a contact form using PHP handler. I need SMTP Authentication to receive the email from website. Can anyone help me to tweak with the existing script so that it includes the SMTP Authentication?

Here's my original script:

Code:
<?php 

$errors = '';
$myemail = 'myemail@email.com';//<-----Put Your email address here.
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['message']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
	$to = $myemail; 
	$email_subject = "Contact form submission: $name";
	$email_body = "You have received a new message. ".
	" Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message"; 
	
	$headers = "From: $myemail\n"; 
	$headers .= "Reply-To: $email_address";
	
	mail($to,$email_subject,$email_body,$headers);
	//redirect to the 'thank you' page
	header('Location: thank-you.html');
	exit();
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>


</body>
</html>
I really need help on this. Thanks!!
#add #email #handler #php
  • Profile picture of the author stephtwy
    Hi,

    Anyone please help?
    Signature
    Stephanie Tan
    steph[at]stephcreativ.com
    http://stephcreativ.com
    {{ DiscussionBoard.errors[8209651].message }}
  • Ill review it now let me see what I can do for you..
    Signature
    WebDevelopmentGroup NYC & CA- Small Business Web Development, App Development, WordPress Development, Graphic Designs, Online Marketing, Local Marketing & more!. "Call us 1.800.219.1314 or message us!". Visit us today! "Now On Live Chat Mon-Fri.". www.WebDevelopmentGroup.org
    (Whitelable our Services)
    ===================================
    ==> #1 OFFLINE MARKETING FORUM ON THE WEB! <==
    www.OFFLINEMARKETINGFORUM.com
    (Register Now)
    {{ DiscussionBoard.errors[8209657].message }}
    • Profile picture of the author stephtwy
      Originally Posted by WebdevelopmentGroup View Post

      Ill review it now let me see what I can do for you..
      Thank you very much!! Any help would be lovely!!
      Signature
      Stephanie Tan
      steph[at]stephcreativ.com
      http://stephcreativ.com
      {{ DiscussionBoard.errors[8210211].message }}

Trending Topics