blue viper
blue viper

Reputation: 1

how to Mail a filled up form to an email address using PHP?

I am trying to send a filled up form to a particular email address. But I have no Idea about it. I know a little PHP coding and as far I have studied online I found that PHP already have a mail() function. but that also have some problems. although most of that I did not understood properly.

here is the things I want to do:

  1. I want to send the filled up form to the particular email address.
  2. I want to send that filled up form to my mobile phone so that i can reply immediately.
  3. I want to send that mail to my inbox only (not spam pr junk).

I am requesting everyone to give me a details information about how I can do so.

thanks in advance..

Upvotes: 0

Views: 403

Answers (3)

Kailash Ahirwar
Kailash Ahirwar

Reputation: 769

Use PHPMailer to send mails in PHP

http://phpmailer.worxware.com/

PHPMailer wiki page:

https://code.google.com/a/apache-extras.org/p/phpmailer/wiki/UsefulTutorial

Use can use Gmail, Live or any other SMTP server to send mails Code:

<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "smtp.example.com"; // SMTP server

$mail->From     = "[email protected]";
$mail->AddAddress("[email protected]");

$mail->Subject  = "First PHPMailer Message";
$mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;

if(!$mail->Send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}

?>

Upvotes: 0

Gopal Joshi
Gopal Joshi

Reputation: 2358

it can help you..

<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "smtp.example.com"; // SMTP server

$mail->From     = "[email protected]";
$mail->AddAddress("[email protected]");

$mail->Subject  = "First PHPMailer Message";
$mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;

if(!$mail->Send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}
?>

Upvotes: 0

sharafatalee
sharafatalee

Reputation: 134

You can simply use php mail function with all the parameters for example mail ( $to ,$subject , $message, $headers ); Where $to, $subject, $message are php variables to contains their respective values. as you are posting data from the form so you can make $message from form. like $message = $_POST['FORM_FIELD_NAME'];

and $headers you set according to your requirement. For example

$headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: My Name <[email protected]>' . "\r\n";

Upvotes: 1

Related Questions