PHP mailto() form - php

I'm working on a contact form currently and it appears to be going through, but I'm not getting the email.I unsure of what the problem is. I'm guessing it's in my PHP, but I don't see where the problem is.
HTML Markup:
<form method="post" id="contact" class="peThemeContactForm" action="mail.php">
<div id="personal" class="bay form-horizontal">
<div class="control-group"><!--name field-->
<div class="controls">
<input class="required span9" type="text" name="author" data-fieldid="0" value="Full Name" onclick="if(this.value=='Full Name') this.value=''" onblur="if(this.value=='') this.value='Full Name'">
</div>
</div>
<div class="control-group"><!--email field-->
<div class="controls">
<input class="required span9" type="email" name="email" data-fieldid="1" value="Your Email" onclick="if(this.value=='Your Email') this.value=''" onblur="if(this.value=='') this.value='Your Email'">
</div>
</div>
<div class="control-group"><!--message field-->
<div class="controls">
<textarea name="message" rows="12" class="required span9" data-fieldid="2" onclick="if(this.value=='Type Message') this.value=''" onblur="if(this.value=='') this.value='Type Message'">Type Message</textarea>
</div>
</div>
<div class="control-group">
<div class="controls send-btn">
<button type="submit" class="contour-btn red">Send Message</button>
</div>
</div>
</div>
<div class="notifications">
<div id="contactFormSent" class="formSent alert alert-success">
<strong>Your Message Has Been Sent!</strong> Thank you for contacting us.</div>
<div id="contactFormError" class="formError alert alert-error">
<strong>Oops, An error has ocurred!</strong> See the marked fields above to fix the errors.</div>
</div>
</form>
PHP:
<?php
if(isset($_POST['email'])){
$mailTo = "jake_ols#live.com";
$subject = "mail from web";
$body = "New message from web
<br><br>
FROM: ".$_POST['email']."<br>
NAME: ".$_POST['author']."<br>
COMMENTS: ".$_POST['message']."<br>";
$headers = "To: Jake <".$mailTo.">\r\n";
$headers .= "From: ".$_POST['author']." <".$_POST['email'].">\r\n";
$headers .= "Content-Type: text/html";
//envio destinatario
$mail_success = mail($mailTo, utf8_decode($subject), utf8_decode($body), $headers);
}
?>

You most likely answer is that the server does not have mail enabled
Use phpinfo() to find which ini file you should be editing and make sure that you php server is set up to send mail.
; For Win32 only.
sendmail_from = me#example.com
Alternatively use SMTP and connect to a service like Mailgun https://documentation.mailgun.com/quickstart-sending.html#send-via-smtp

Related

PHP Contact form just.. stopped.. working [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 2 years ago.
I had my contact form up and running and I was doing a bit of housekeeping with how it actually looked when it arrived in my inbox. I dunno what I changed but even after reverting it back to when I know it was working it no longer sends emails but it 100% was working at some point!
Maybe its an issue with the host or the server but I've no clue.
Here is the contact form php.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$emailFrom = 'myemail#gmail.com';
$emailSubject = 'New Form Submission';
$emailBody = "Name: $name. \n".
"Email: $email. \n".
"Phone: $phone 'n".
"Message: $message.";
$to = 'myemail#gmail.com';
$headers = "From: $emailFrom \r\n";
$headers .= "Reply to $email \r\n";
mail($to,$emailSubject,$emailBody,$headers);
header("Location: index.php")
?>
And here is the forms html
<div id="contact" class="container contact-form">
<div id="contactAnchor"></div><!--CONTACT ANCHOR TAG-->
<div class="contact-image">
<img id="contactLogo" src="/img/sam avatar no bg.png" width="150px" alt="SDB logo"/>
</div>
<form method="post" action="contactform.php">
<h3>Drop Me a Message</h3>
<div class="row">
<div class="col">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Your Name *"/>
</div>
<div class="form-group">
<input type="text" name="email" class="form-control" placeholder="Your Email *"/>
</div>
<div class="form-group">
<input type="text" name="phone" class="form-control" placeholder="Your Phone Number"/>
</div>
</div>
<div class="col">
<div class="form-group">
<textarea name="message" class="form-control" placeholder="Your Message *" style="width: 100%; height: 150px;"></textarea>
</div>
<div class="form-group">
<input type="submit" name="btnSubmit" class="btn btn-success" value="Send Message" />
</div>
</div>
</div>
</form>
</div>
Not sure if this solves it, but your reply to header is incorrect:
$headers .= "Reply-To: $email \r\n";

Php mail not submitting and blank page displaying

I am using Ampps on Mac and trying to send an email using php from a contact form however I do not receive the mail and when the form is submitted it redirects me to the file page resulting in a blank display
my form :
<form action="email.php" method="post">
<div class="col-md-6 w3_agileits_contact_left">
<span class="input input--akira">
<input class="input__field input__field--akira" type="text" id="input-22" name="Name" placeholder="" required="" />
<label class="input__label input__label--akira" for="input-22">
<span class="input__label-content input__label-content--akira">Your name</span>
</label>
</span>
<span class="input input--akira">
<input class="input__field input__field--akira" type="email" id="input-23" name="Email" placeholder="" required="" />
<label class="input__label input__label--akira" for="input-23">
<span class="input__label-content input__label-content--akira">Your email</span>
</label>
</span>
<span class="input input--akira">
<input class="input__field input__field--akira" type="text" id="input-24" name="Subject" placeholder="" required="" />
<label class="input__label input__label--akira" for="input-24">
<span class="input__label-content input__label-content--akira">Your subject</span>
</label>
</span>
</div>
<div class="col-md-6 w3_agileits_contact_right">
<div class="w3_agileits_contact_right1">
<textarea name="Message" id="Message" placeholder="Your comment here..." required=""></textarea>
</div>
<div class="w3_agileits_contact_right2">
<input type="submit" value="Send">
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</form>
my File :
$email = $_POST['Email'];
$name = $_POST['Name'];
$to = "lucvanrooyen#gmail.com";
$subject = $_POST['Subject'];
$userMessage =$_POST['Message'];
$headers = "From: $email\n";
$message = "$name has sent you the following message.\n
Message: $userMessage";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: lucvanrooyen#gmail.com\n";
$usermessage = "Thank you for your enquiry we will be in touch.";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
The code you have shown is not enough to debug your problem.
If you are using the mail method which is built into the standard library, read this answer to find out a few troubleshooting steps you could follow.
If you are and are still finding it difficult to use, then you could consider using one of the PHP emailing solutions like -
PHPMailer
SwiftMailer
Please check your form tag. there is no opening tag for form
<form action="email.php" method="post">

php contact form, not receiving emails [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
please assist with my PHP form. Following this text I have both my HTML form as well as my PHP page described. I am not receiving the e-mails when I attempt to use the form on my website. I have validated that my e-mail address is working, and that should not be the issue.
The following is my HTML form:
<!-- Contact Form -->
<div class="col-md-6 col-sm-6">
<hr>
<p>Have a question or comment? Fill out the form below.</p>
<div class="contact-form wow fadeInLeft showdelay2">
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group form-group">
<div class="controls">
<label>Name</label>
<input type="text" class="form-control dark" id="name" placeholder="Name" required data-validation-required-message="Please enter your name.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email</label>
<input type="email" class="form-control dark" id="email" placeholder="Email Address" required data-validation-required-message="Please enter your email address.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Message</label>
<textarea class="form-control dark" rows="7" id="message" placeholder="Message" required data-validation-required-message="Please enter your message" maxlength="999" style="resize:none"></textarea>
<p class="help-block"></p>
</div>
</div>
<div id="success"></div>
<div class="pull-right">
<button type="submit" class="btn btn-info btn-lg">Submit</button>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
<!-- ./contact form -->
The following code is my contact_me.php page, which doesn't appear to be working.
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// create email body and send it
$to = 'email#addresss.com'; 'email#address.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Contact form from: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: info#bootstrapwizard.info\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
your to string is incorrect, the valid format is:
$to = 'AdrianPham#crosshatcheatery.com,Webmaster#crosshatcheatery.com';
the headers should end with "\r\n"
$headers = "From: info#bootstrapwizard.info\r\n";
$headers .= "Reply-To: $email_address";

PHP POST / Bootstrap Form

Im not receiving emails from my email form.
I created a simple form that takes 4 fields and sends them to our emails. I tested my php code with no errors. I double checked the html to see if the script was referring properly which it was. I believe that the ids and names are correct. I also triple checked the variables I created on the php code. I've googled everything I could come up with no luck. Thanks!
var dump $body shows
Thank you! One of our station representatives will contact you soon.
string(119) "
Name: TEST
Email: test#emaol.com
Station: 1234
Message:
I need help with.
FORM
<form class="form-horizontal" role="form" method="post" action="feedback.php">
<fieldset>
<!-- Form Name -->
<legend>Our team will reach out to you as soon as possible.</legend>
<!-- Text input-->
<div class="control-group col-xs-4">
<label class="control-label" for="textinput">Full Name</label>
<div class="controls">
<input id="name" name="name" placeholder="John Doe" class="input-xlarge" type="text">
</div>
</div>
<!-- Text input-->
<div class="control-group col-xs-4">
<label class="control-label" for="textinput">E-Mail</label>
<div class="controls">
<input id="email" name="email" placeholder="affiliate.marketing.app#123.com" class="input-xlarge" type="text">
</div>
</div>
<!-- Text input-->
<div class="control-group col-xs-4">
<label class="control-label" for="textinput">Station Code</label>
<div class="controls">
<input id="station" name="station" placeholder="xxx" class="input-xlarge" type="text">
</div>
</div>
<!-- Textarea -->
<div class="control-group">
<label class="control-label" for="textarea">Message</label>
<div class="controls">
<textarea id="message" name="message">I need help with....</textarea>
</div>
</div>
<!-- Button -->
<div class="control-group">
<label class="control-label" for="submit"></label>
<div class="controls">
<button type="submit" id="submit" value="Send" name="singlebutton" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
PHP PAGE
<?php
/* These are the variable that tell the subject of the email and where the email will be sent.*/
$emailSubject = 'Station App Support Request';
$mailto = 'myemail#domain.com, myemail2#domain.com';
/* These will gather what the user has typed into the fieled. */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$stationField = $_POST['station'];
$messageField = $_POST['message'];
/* This takes the information and lines it up the way you want it to be sent in the email. */
$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Station: $stationField <br>
Message: $messageField <br>
EOD;
$headers = "From: $emailField\r\n"; // This takes the email and displays it as who this email is from.
$headers .= "Content-type: text/html\r\n"; // This tells the server to turn the coding into the text.
$success = mail($mailto, $emailSubject, $body, $headers); // This tells the server what to send.
?>

Trouble with PHP sending emailing from contact form

I have a site up and running and cant seem to get the php to send the form data. Get thank you message sometimes but never appears in mail. my aim is to have the form collect the data then email the data to the client.
Thanks for any help. I am struggling to get to grips with php it would appear.
<?php
$to = "********#*******.com";
$subject = "Contact Us";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['enquiry'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully";}
else
{print "We encountered anerror sending your mail";}
?>
<section class="container">
<section class="col-lg-6 col-lg-offset-1">
<form class="form-horizontal text-center" role="form" method="post" action="form_send.php">
<div class="form-group">
<label for="Name" class="col-lg-2 control-label">Name:</label>
<div class="col-lg-6">
<input type="name" class="form-control" id="name" name="name" placeholder="Enter Name...">
</div>
</div>
<div class="form-group">
<label for="Email" class="col-lg-2 control-label">Email:</label>
<div class="col-lg-6">
<input type="email" class="form-control" id="email" name="email" placeholder="Enter Email...">
</div>
</div>
<div class="form-group">
<label for="Phone" class="col-lg-2 control-label">Phone:</label>
<div class="col-lg-6">
<input type="phone" class="form-control" id="phone" placeholder="Enter Phone Number...">
</div>
</div>
<div class="form-group">
<label for="Enquiry" class="col-lg-2 control-label">Enquiry:</label>
<div class="col-lg-6">
<textarea type="enquiry" class="form-control" rows="5" id="enquiry" name="enquiry" placeholder="Enter Email..."></textarea>
</div>
</div>
<div class="form-group">
<label for="Enquiry" class="col-lg-2 control-label"></label>
<div class="col-lg-6">
<button class="btn btn-primary" type="submit">Send Message</button>
</div>
</div>
</form>
Reply from email server:
Technical details of permanent failure: Google tried to deliver your message, but it was rejected by the server for the recipient domain peoplespropertyshop.co.uk by aspmx.l.google.com. [2607:f8b0:4003:c02::1a]. The error that the other server returned was: 550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 support.google.com/mail/bin/answer.py?answer=6596 t6si822722oei.44 - gsmtp
First you should check that your code is in one file (form_send.php). After that add some check if user have submitted the form:
if (!empty($_POST))
Message is sent to $to email. If you want to change that, pass $email paramter to mail() function:
$sent = mail($to, $subject, $message, $headers) ;
to:
$sent = mail($email, $subject, $message, $headers);
Also check your mail server configuration and add some validation.
$email = htmlentities($_REQUEST['email']);
$message = htmlentities($_REQUEST['enquiry']);

Categories