Error - Client Mail - "Relaying not permitted" - php

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!";
?>

Related

How to send mail from bootstrap form on completition and submission to a mail address?

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 need to send user a copy of the placed order in the form

Iam using the following php code in my order form
I need to send user a copy of his/her placed order other than the owner mail. I don't know how to write code in $recepient for sending a copy to user also. I need to use "$Email" for the user email id.
Please give me suggestion for writing code.
My php code for order form is as follows:
<?php
$Email = #trim(stripslashes($_POST['Email']));
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Business = $_POST['Business'];
$phone= $_POST['phone'];
$productid= $_POST['productid'];
$producttype= $_POST['producttype'];
$Productquantity= $_POST['Productquantity'];
$Shippingaddress= $_POST['Shippingaddress'];
$Message = $_POST['Message'];
$formcontent=
"$Name is sending you a request for the product enquiry. \n
Details of the Product Enquiry person are as follows- \n
Name: $Name \n
Contact Number: $phone \n
Email: $Email \n
Business Name/Company Name: $Business \n
Product Id: $productid \n
Product Type: $producttype \n
Product Quantity: $Productquantity \n
Comment: $Message \n
Shipping Address: $Shippingaddress";
$recipient = "info#domain.com";
$subject = "Request for Product Enquiry";
$mailheader = "From: $Name \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "<h4><font color='#2A007D'><strong><center>Thank You $Name !
We have received your Order details and
we will contact you as soon as possible.
<br>Your Order details has been sent to your Email also.
</center></strong></font></h4>";
?>
You could call mail() again with the user's email address, so:
mail($Email, $subject, $formcontent, $mailheader);
although you may want to change the message text too.
$mail = mail($recipient, $subject, $formcontent, $mailheader);
if(!$mail)
{
echo <h4><font color='red'>Failed</font></h4>;
}
else
{
echo "<h4><font color='#2A007D'><strong><center>Thank You $Name ! We have received your Order details and we will contact you as soon as possible. <br>Your Order details has been sent to your Email also.</center></strong></font></h4>";
}
?>

Contact form sends everything to spam

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?

.PHP email form sends but empty fields are received

I have made a .PHP file that when the email form is filled out it sends it to my email address. Now this all works fine, I get the email, but, I get empty fields, here is the email I received from my test:
"Name:
Email:
Messages: "
as you see, all the fields are empty even though they were filled out.
Here is the code for the .php file:
<?php
$first_name = $_POST['name'];
$email_message = $_POST['email'];
$message = $_POST['message'];
$headers = "Website message";
$headers = "From: $_email";
$to = 'enquiries#ajmoger.co.uk';
$subject = 'AJ Moger website comment submission';
$message = "
Name: $first_name \n
Email: $email_message \n
Messages: $message \n";
mail($to, $subject, $message, $headers);
header("Location: thank_you.html");
die();
?>'
and here is the HTML code for the form:
The reason is enctype="text/plain" on your <form>. Remove that from your <form> code.
There seems like a bug was filed on this topic , but the status is closed. So it's better not to use that encoding type.

When receiving email's I only get my email address as "sent from." although it was sent from another email address. What should I add or change?

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.

Categories