When I tried to submit the form , It's been sent successfully , But I didn't get any data in the email . Here's my code :
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="email.php" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
$to = "aryanpallive#gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
$to = "acbhaskar1#gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
if(mail($to,$subject,$message,$headers)){
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
else{echo "mail has not been sent";}
}
?>
[![Output][1]][1]
[1]: https://i.stack.imgur.com/hgY1g.png
try it
$to = 'aryanpallive#gmail.com';
$subject = "Form submission";
$message = 'testing';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
check your INBOX otherwise check your spam
Related
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 2 years ago.
I would like to send an email from a PHP script. I installed an Apache server on Ubuntu machine, and that's all. I prepared an index.html file:
<?php
if(isset($_POST['submit'])){
ini_set("SMTP", "smtp.gmail.com");
ini_set("sendmail_from", "xxxx#gmail.com");
ini_set("smtp_port", "587");
$to = "MY_ADDRESS#gmail.com"; // this is your Email address
$from = "xxxx#gmail.com"; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['email'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
I allowed the usage of the gmail on gmail settings, but the email is not being sent. Any ideas why?
you can use those credentials for testing: tmail4824#gmail.com, password: XXX_12345. Email sanding from Python (using the same credentials) works.
?php
$name ="";
$Email = "";
$service = "";
$Subject = "";
$phone = "";
if(isset($_POST['item.name']))
{
$name = $_POST['name'];
$Email = $_POST['email'];
$Subject = $_POST['subject'];
$Msg = $_POST['message'];
$phone = $_POST['phone'];
$mailTo = "xxxxxxxxxxxxxx";
$headers = "from :".$Email;
$txt = "xxxx\n\n".$name.".\n\n".$Email.".\n\n".$phone.".\n\n".$Msg;
mail($mailTo, $Subject, $txt, $headers);
header("location: xxx.php?mailsend");
}
?>
<?php
if(isset($_POST['submit'])){
$to = "abpaple#gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
i'm working on php mail sending concept, im not getting how to solve this error please if any one can help me it will be help full for me. im getting such kind of error
Warning: mail(): SMTP server response: 530 SMTP authentication is
required. in C:\xampp\htdocs\Message_delivering\1.php on line 14
Warning: mail(): SMTP server response: 530 SMTP authentication is
required. in C:\xampp\htdocs\Message_delivering\1.php on line 15
<?php
if(isset($_POST['submit'])) {
$to = "receiver#domain.com"; // this is IT Support Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name']; // sender's first name
$last_name = $_POST['last_name']; // sender's last name
$subject = "Form submission"; // Email confirmation submission
from sender
$subject2 = "Copy of your form submission"; // Email confirmation submission
from receiver
$message = $first_name . " " . $last_name . " requested:" . "\n\n" . $_POST['message']; // Email header
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to, $subject, $message, $headers);
mail($from, $subject2, $message2, $headers2); // sends a copy of the message to the sender
echo "Request Submitted Succesfully. Thank you " . $first_name . ", we will
fulfill your request shortly.";
// You can also use header('Location: thank_you.php'); to redirect to
another page.
}
?>
<!DOCTYPE html>
<head>
<title>Device and Set Up Request Form</title>
</head>
<body>
<form action="" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
How do I add more labels below the message for the users to fill? For example, right after "Message:," I want to add "Supervisor name" and more labels. In addition, those labels not only appear on the website, but also is wrapped and get emailed to the receiver.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
hey guys i'm trying to send a form to an email and that's my form :
<?php
error_reporting(0);
if(isset($_POST['submit'])){
$to = "elbiheiry2#gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="form.php" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Image: <input type="file" name="image_name"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
every time i click submit it tells me the mail is sent but when i check my inbox i find nothing can anyone help ???
I would suggest you switch to PHPMailer, it will take care of email configurations for you.
I've tried every php contact form tutorial but I can't get any of them to send the email properly. They all just show the code but don't send the email. This is the HTML code I have right now:
<form method="POST" action="scripts/contact.php">
<input id="name" name="name" placeholder="Name*" type="text" /> <br>
<input id="subject" name="subject" placeholder="Subject" type="text" /> <br>
<input id="email_address" name="email" placeholder="Email address*" type="text" /> <br>
<textarea id="message" name="message" placeholder="Your message*"></textarea>
<input id="submit" type="submit" name="submit" value="Send" />
</form>
and this is the php I have:
<?php
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "benmuschol#gmail.com";
$subject = "Hello World";
$message = "Name: $name \n Subject: $subject \n Email: $email \n Message: $message \n";
$headers = "From: $email" . $email;
mail($name,$email,$subject,$message,$headers);
echo "Mail Sent.";
?>
I have decent knowledge of HTMl but next to none of PHP. Any help would be greatly appreciated.
first you be sure that php file is exist in path scripts/contact.php
second look at phpinfo or php.ini for find is smptp server was setting or not
use following php code:
<?php
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "benmuschol#gmail.com";
$subject = "Hello World";
$message = "Name: $name \n Subject: $subject \n Email: $email \n Message: $message \n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: '.$email. "\r\n";
if(mail($to, $subject, $message, $headers))
{
echo "Mail Sent Successfully.";
}
else
{
echo "Error in Mail Sent.";
}
?>