Hello Guys!
I need A help for Auto email Generation when A form is submitted. A email Should Send to the web site Admin or wotever from Who filled the form, Form Filled Details! Please Help Me I Tried Many Ways but Still couldnt.. Please Help. and form details are on database!

Recommended Answers

All 7 Replies

When you say that;

I Tried Many Ways but Still couldnt..

What exactly did you try?? Can you share with us?

I refferes sme tutorials on Web But I couldnt, Im new to Php though Please any help

I followed Some Tutorials on W3School.com But i couldn't email is not generatin??

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("irfathft@yahoo.com", $subject,
  $message, "From:" . $email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='emailgene.php'>
  Email: <input name='email' type='text'><br>
  Subject: <input name='subject' type='text'><br>
  Message:<br>
  <textarea name='message' rows='15' cols='40'>
  </textarea><br>
  <input type='submit'>
  </form>";
  }
?>

Try this one. It should work.
But first, you'll need to download the phpMailer class, and then create your HTML form with Name, subject, message; just as shown in the code below

<?php
require("PHPMailer_5.2.4/class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "localhost";
    $mail->From = "source_address@domain.com";
    $mail->FromName  =  "Name of sender";
    $email_add = $_POST['email'];
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $msg = $_POST['email_message']."\n".$name.".";
    $mail->AddAddress("add_address@domain.com");
    $mail->AddAddress("address2@domain.com");

    $mail->SMTPAuth = "true";
    $mail->Username = "my_gmail_address@gmail.com";
    $mail->Password =  "my_gmail_password";
    $mail->Port  =  "25";

    $mail->name = $name;
    $mail->Subject = $subject;
    $mail->Body = $msg;
    $mail->WordWrap = 50;

    if(!$mail->Send())
    {
echo "<script language='javascript'>
alert('Your email was NOT sent! Please try again.')
</script>
<script>
window.location='index.php'
</script>";
    }
    else
    {
    echo "<script language='javascript'>
alert('Mail Successfully sent! Thank you for contacting us.')
</script>
<script>
window.location='index.php'
</script>";
    }

?>

Webville312 Thak you very much For your help Your Code You mentioned this
$mail->AddAddress("add_address@domain.com");
$mail->AddAddress("address2@domain.com");
What is this means> please

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.