My contact form works fine but sends everything to spam when I set the recipient as Gmail account and sends nothing if I set it as my domain email client (eg info#mydomain.com). Is there something wrong in the code? What do I need to do?
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "info#mydomain.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: message-sent.html#contact'); exit();
?>
Second question. I set up the location to redirect a user to a thank-you page. How can I set it to open in a new tab instead?
Related
Hi guys I have the ff codes:
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "gogel.rob#gmail.com";
$subject = "Chick SEO Contact Form: New Email from $name";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank you!";
?>
Right now its only redirecting the page to a simple echo page with text "Thank you"
Is there anyway we can redirect the user to this URL https://recurpost.com/ once the form was submitted and the email was sent instead of sending it to echo?
You need to use the Php header function. Instead of the echo, you can use the following:
header("Location: https://recurpost.com/");
The above code will include a "location" header in the Http response. This will cause the browser to redirect the user to the given url. See the documentation for the header function
Try using
<?php
echo "
<script>
window.location.replace('https://urdomain.org/successpage');
</script>
";
I have created a bootstrap form .. lets say it is for a survey and it generally has a lot of yes no questions . with radio buttons and some text fields for the name,time, date and remarks.. here i want to send the completely filled form to the mail address of admin .. what should be done i am using bootstrap for this..
I tried this but it is not much applicable to me .. it sends the mail but all the forms are not sent by it.. please help..
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "emailaddress#here.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
Use ini_set to change smtp, port, Authorization details, sendmailfrom etc in this script and then use mail function. Hope it will help.
Ex:-
ini_set("SMTP", "smtp.google.com");
I have an contact form on my Wordpress blog. It currently cannot send the form submission to my email anymore. The message in my mail client as below:
"A message that you sent was rejected by the local scanning code that
checks incoming messages on this system. The following error was given:
"Relaying not permitted" "
I believe it needs authentication. So to solve that i need to input my client email and password into the PHP file. But I do not exactly how to input the email and password info into PHP file correctly?
My PHP code as below. Please show me how to input mail client info into this PHP file.
<?php
$name = $_POST['name'];
$pickupadd = $_POST['pickupadd'];
$pickuppc= $_POST['pickuppc'];
$dropoffadd= $_POST['dropoffadd'];
$dropoffpc= $_POST['dropoffpc'];
$phonenumber= $_POST['phonenumber'];
$useremail = $_POST['email'];
$message = $_POST['message'];
$formcontent=" From: $name \n Pick Up Address: $pickupadd \n Pick Up Post Code: $pickuppc\n Drop Off Address: $dropoffadd\n Drop Off Post Code:$dropoffpc\n Fone Number: $phonenumber\n Email: $useremail\n Message: $message";
$recipient = "myemail#gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!") ;
echo "Thank You!";
?>
I created a web forum with the script below. I am able to receive inquiries from my site; however, the visitor's email address is not showing in the email sent from the webmaster. I would like to have some guidance here to fix the problem.
Here is my PHP script:
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "abc#gmail.com";
$subject = "Contact Form";
mail($recipient, $subject, $formcontent) or die("Error!");
echo "Thank You!";
?>
Here is what I got from the webmaster:
From: xx
Message: xx
No email address listed in the email sent by the webmaster.
I found some similar scripts on the web with two additional rows:
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
This actually gives me an Error output.
How can I fix the issue?
Thanks!
The third parameter of mail() is just the actual body of the message, which you have saved as $message. The fourth variable is where you define the headers, and is where you define who the message is From. Note that you don't actually need to pass the message as a header, and as such, your variable $formcontent, shouldn't contain your From: header. However, you do need to provide carriage returns in the form of "\r\n" after the provided email address.
The modified code would look like this:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent = "From: $name" . "\r\n";
$recipient = "abc#gmail.com";
$subject = "Contact Form";
mail($recipient, $subject, $message, $formcontent) or die("Error!");
echo "Thank You!";
?>
Hope this helps! :)
You could add headers to the mail function.
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "abc#gmail.com";
$subject = "Contact Form";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: <$email>" . "\r\n";
mail($recipient, $subject, $formcontent, $headers);
FYI - I would santize and validate all POST values before using them in this manner
So I'm using this code for php mail and I keep getting MY email address rather than the actualy senders email, when I test it on my website's contact form. Any help? By the way, I use my email in the recipients address.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Type: $type \n Message: $message";
$recipient = "myemail#address.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
?>
Have a look at php:mail manual in the example#3 you can see,
<?php
mail('nobody#example.com', 'the subject', 'the message', null,'-fwebmaster#example.com');
?>
You can see
The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path.