PHP mail function, whats wrong here? - php

The following code sends me an email holding the following variables. One of the last if statements says if(mail) then echo "You will be contacted soon". When the script runs I get echoed back "You will be contacted soon", however, I never receive an email.
I do have a smaller contact script (posted after this first and larger one) that does work.
Note: contants.php and functions.php are both included and work fine
WEBMASTER_EMAIL is defined in contanstants.php and is correct, because
my smaller contact script uses the same variable, and emails me fine.
Thanks for the help
<?php
// pull constant variables
include("php/constants.php");
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post) {
include ("php/functions.php");
}
// general info
$name = stripslashes($_POST['contact']);
$phone = $_POST['phone'];
$email = trim($_POST['email']);
$time_to_reach = $_POST['time-to-reach']; // what the best time to reach them?
// delivery info
$delivery_address = $_POST['del-address'];
$delivery_city = $_POST['del-city'];
$delivery_state = $_POST['del-state'];
$delivery_zip = $_POST['del-zip'];
// moving city info if applicable
$moving_address = $_POST['move-address'];
$moving_city = $_POST['move-city'];
$moving_state = $_POST['move-state'];
$moving_zip = $_POST['move-zip'];
// date needed
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];
// how long do you need the storage?
$storage_length = $_POST['time-length'];
// how many containers do you need?
$quantity_containers = $_POST['number-of-containers'];
// how did you hear about us?
$tracker = $_POST['tracker'];
// message
$message_holder = htmlspecialchars($_POST['message']);
$error = '';
// check general info
if(!$name) { $error .= 'Please enter your name.<br />'; }
if(!$email) { $error .= 'Please enter an e-mail address.<br />'; }
if($email && !ValidateEmail($email)) { $error .= 'Please enter a valid e-mail address.<br />'; }
if(!$time_to_reach) { $error .= 'Please select the best time to reach you.<br />'; }
// check delivery info
if(!$delivery_address) { $error .= 'Please enter you current address.<br />'; }
if(!$delivery_city) { $error .= 'Please enter your current city.<br />'; }
if(!$delivery_state) { $error .= 'Please enter your current state.<br />'; }
if(!$delivery_zip) { $error .= 'Please enter your current zip code.<br />'; }
// check date needed
if(!$month) { $error .= 'Please enter the approximate date you need the storage.<br />'; }
if(!$day) { $error .= 'Please enter the approximate date you need the storage.<br />'; }
if(!$year) { $error .= 'Please enter the approximate date you need the storage.<br />'; }
// check length of time needed
if(!$storage_length) { $error .= 'Approximatly how long will you need the storage unit for?<br />'; }
// check quantity of storages
if(!$quantity_containers) { $error .= 'How many containers will you need?<br />'; }
// check advertising tracker
if(!$tracker) { $error .= 'Please let us know how you\'ve heard of us.<br />'; }
// check message (length)
if(!$message_holder || strlen($message_holder) < 10) {
$error .= "Please enter your message. It should have at least 10 characters.<br />";
}
// build email message
$message = "Name: {$name}
Phone: {$phone}
Email: {$email}
Best time to reach: {$time_to_reach}\n
-----------------------------------------------------
Delivery address: {$delivery_address}
{$delivery_city}, {$delivery_state} {$delivery_zip}
Moving address: {$moving_address}
{$moving_city}, {$moving_state} {$moving_zip}
-----------------------------------------------------
Date needed: {$month}/{$day}/{$year}
Length of time needed: {$storage_length}
Number of containers: {$quantity_containers}
Where did you hear about us?
{$tracker}\n
Message: {$message_holder}\n";
if(!$error) {
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
"From: residential-quote#stocor.com\r\n"
."Reply-To: ".$name."<".$email.">\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail) {
echo '<p>Thank you, you will be contacted soon.</p>';
}
} else {
echo '<div class="notification_error">'.$error.'</div>';
}
?>
The following script, contact script, does work meaning I receive an email.
<?php
// pull constant variables
include("php/constants.php");
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post) {
include ("php/functions.php");
}
// variables
$name = stripslashes($_POST['name']);
$phone = $_POST['phone'];
$email = trim($_POST['email']);
$tracker = $_POST['tracker'];
$message_holder = htmlspecialchars($_POST['message']);
$error = '';
// check name
if(!$name) {
$error .= 'Please enter your name.<br />';
}
// check email
if(!$email) {
$error .= 'Please enter an e-mail address.<br />';
}
// validate email
if($email && !ValidateEmail($email)) {
$error .= 'Please enter a valid e-mail address.<br />';
}
// check advertising tracker
if(!$tracker) {
$error .= 'Please let us know how you\'ve heard of us.';
}
// check message (length)
if(!$message_holder || strlen($message_holder) < 10) {
$error .= "Please enter your message. It should have at least 10 characters.<br />";
}
// build email message
$message = "Name: {$name} \n
Phone: {$phone} \n
Email: {$email} \n
Where did you hear about us?
{$tracker}\n\n
Message: {$message_holder}\n";
if(!$error) {
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
"From: contact#stocor.com\r\n"
."Reply-To: ".$name."<".$email.">\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail) {
//header("Location: thank_you.php");
echo "Thank you. You will be contacted soon.";
}
} else {
echo '<div class="notification_error">'.$error.'</div>';
}
?>

Using the naked mail function is just asking for trouble ( http://en.wikipedia.org/wiki/E-mail_injection , php specific info: http://www.damonkohler.com/2008/12/email-injection.html ), and prevents simple debugging. I suggest you use an object wrapper around the mail function, both because this has benefits when you filter the headers, by making it a non-standard target for php mail form header injection spammers, and by allowing you to debug the messages easier by just dumping the created mail object and reviewing it's contents. For debugging it also allows you to provide a "just echo out the mail at the end" alternative for local testing on machines where you don't have/don't want to have a mail server, and don't want to even try to send out mail while you're just testing functionality.
Here is a wrapper (freely available for modification and use) that I created and use myself:
http://github.com/tchalvak/ninjawars/blob/master/deploy/lib/obj/Nmail.class.php
Alternatively just check out PEAR mail: http://pear.php.net/package/Mail/

It's not jumping out at me, why don't you try turning the errors all the way up and see if that works.
error_reporting(1);
At the top of the script.

EDIT: Sorry, I see now you do have error reporting turned on. Make sure your INI file is set properly too. Try removing the ^ E_NOTICE so that you see those warnings, too.
I've had problems where mail() wouldn't say anything at all (and it would execute as if successful) when it didn't really. If you're bent on using mail(), you can use SwiftMailer, which generally throws helpful exceptions when something goes awry and includes a transport class Swift_MailTransport which uses mail() but is all dressed up in a nice object-oriented interface.

So, due to the nature of the problem (mail is being accepted for delivery - $mail is true), the problem is likely in the message content. Do you have access to the mail server itself? Can you check the logs? var_dump() the $subject, $message, and set the headers to a var and var_dump() that as well. Examine the contents with a fine tooth comb. Remove suspect characters and line breaks until it does work.
One thing to try... (though, the fact that your other mail is being accepted says this is likely not the case)
http://www.php.net/manual/en/function.mail.php
If messages are not received, try
using a LF (\n) only. Some poor
quality Unix mail transfer agents
replace LF by CRLF automatically
(which leads to doubling CR if CRLF is
used). This should be a last resort,
as it does not comply with ยป RFC 2822.
The problem with mail() is that its just feeding mail to the local sendmail daemon. It doesn't give you any active feedback on the mail, and the relay headers sometimes get you spam de-rated.
I'd check out http://sourceforge.net/projects/phpmailer/

Try wrapping lines in the message to 70 characters with
$message = wordwrap($message, 70);
Try replacing \r\n in the additional headers with \n in case your mail function is replacing \n for \r\n and you're ending-up with \r\r\n

Related

Mail script won't send every field

Sorry for the stupid question (I'm just starting out) but I can't quite understand why the phone field of my PHP script won't appear in the email I receive. I've added the field in HTML in works fine, the error message if the phone field is empty works good but if I run it, the email I receive will not contain the field.
Here is the PHP mail script:
<?php
require('email_config.php');
// sender information
$name = trim($_POST['name']);
$phone = trim($_POST['phone']);
$email = trim($_POST['email']);
$message = trim($_POST['message']);
$error = "";
// check sender information
$pattern = "^([a-zA-Z0-9_\-\.]+)#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$^";
if(!preg_match_all($pattern, $email, $out)) {
$error = $invalid_email; // for invalid email
}
if(!$email) {
$error = $invalid_email; // for empty email field
}
if (!$phone) {
$error = $invalid_phone; // for empty phone field
}
if(!$message) {
$error = $invalid_message; // for empty message field
}
if (!$name) {
$error = $invalid_name; // for empty name field
}
// email header
$headers = "From: ".$name." <".$email.">\r\nReply-To: ".$email."";
if (!$error){
// sending email
$sent = mail($to_email,$subject,$message,$headers);
if ($sent) {
// if message sent successfully
echo "SEND";
} else {
// error message
echo $sending_error;
}
} else {
echo $error; // error message
}
?>
Thanks in advance!
Looks like you skipped adding the phone to the message, Your message
should be something like this
$message = trim($_POST['message']).' \n Phone: '.trim($_POST['phone']);
Seems like you are sending with plan text email so i used the new line special character /n.
To learn more about the special string characters
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single

how to make email appear in inbox and not junk email (php)

I have written a php mail function to allow a user on my website to fill in a form and send the form to my email. as the question says the email is working once the user send the form however it only appear in my junk email folder instead, i am not a php developer but after doing some research i have noticed a lot people mentione about PHPMailer which i never heard of or used before.
i would much appreciate with a bit oh help.
$to="myemail.com";
//Errors
$nameError="";
$emailError="";
$errMsg="";
$errors="";//counting errors
$name="";
$email="";
$message="";
if(isset($_POST['send'])){
if(empty($_POST['yourname'])){ //name field empty
$nameError="Please enter your name";
$errors++; // increament errors
}else{
$name= UserInput($_POST['yourname']);
if(!preg_match("/^[a-zA-Z ]*$/", $name)){
$nameError="Only letters and white space accepted";
$errors++;
}
}
if(empty($_POST['email'])){
$emailError="Enter email";
$errors++;
}else{
$email = UserInput($_POST['email']);
if(!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email)){
$emailError="Invalid Email";
$errors++;
}
}
if(empty($_POST['msg'])){
$errMsg="Enter message";
$errors++;
}else{
$message=UserInput($_POST['msg']);
}
if($errors <=0){//No errors lets setup our email and send it
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <' . $email . '>' . "\r\n";
$text = "<p>New Message from $name </p>";
$text .= "<p>Name : $name</p>";
$text .= "<p>Email : $email</p>";
$text .= "<p>Message : $message</p>";
mail($to, "Website Contact", $text, $headers);
$success="Thank your message was submitted";
$_POST= array(); //clearing inputs fields after success
}
}
//Filter user input
function UserInput($data){
$data = trim($data);
$data = stripcslashes($data);
$data = htmlspecialchars($data);
return $data;
}
Your using the email from their posted variable in your header. When your email server receives this it's going to look like it is spoofed because it is. Your site isn't going to be one of the mail servers setup for that domain.
When setting up MX and DNS records for email you use SPF or key signing to prove who sent the message and that it came from a trusted mail server for that domain. You may want to change the from to be an email and domain you control. You are getting their email in the body anyway.
Worst case if you don't have control over SPF records you could at least mark the from email, assuming it is something you control, as always trusted so it wouldn't go into your junk mail.
$headers .= 'From: <' . $to . '>' . "\r\n";

PHP mail form is being sent to Gmail spam [duplicate]

This question already has answers here:
How do you make sure email you send programmatically is not automatically marked as spam?
(24 answers)
Closed 7 years ago.
Can someone help me figure out why the below PHP is causing the email to be sent to Gmail spam? I tried following other directions for setting proper headers, but I still run into problems with my emails going into the spam filter in Gmail.
Any help would be appreciated!
<?php
//set validation error flag as false
$error = false;
//check if form is submitted
if (isset($_POST['submit']))
{
$name = trim($_POST['txt_name']);
$fromemail = trim($_POST['txt_email']);
$inquiry = trim($_POST['txt_inquiry']);
$message = trim($_POST['txt_msg']);
//name can contain only alpha characters and space
if (!preg_match("/^[a-zA-Z ]+$/",$name))
{
$error = true;
$name_error = "Please enter a real name";
}
if(!filter_var($fromemail,FILTER_VALIDATE_EMAIL))
{
$error = true;
$fromemail_error = "Please enter a valid email address";
}
if(empty($inquiry))
{
$error = true;
$inquiry_error = "Please enter your subject";
}
if(empty($message))
{
$error = true;
$message_error = "Please enter your message";
}
if (!$error)
{
//send mail
$toemail = "myemail#gmail.com";
$subject = "inquiry from visitor " . $name;
$body = "Here goes your Message Details: \n\n Name: $name \n From: $fromemail \n Inquiry: $inquiry \n Message: \n $message";
$headers = "From: $fromemail\n";
$headers .= "Reply-To: $fromemail";
$headers .= "Return-Path: $fromemail";
if (mail ($toemail, $inquiry, $body, $headers))
$alertmsg = '<div class="alert alert-success text-center">Message sent successfully. We will get back to you shortly!</div>';
else
$alertmsg = '<div class="alert alert-danger text-center">There is error in sending mail. Please try again later.</div>';
}
}
?>
It could be that your ip address of the server that you are sending the email with it used for other purposes that marked it as a spam address.
Most of the time when you add DKIM and SPF to your email server (if you use one) will solve this problem.
An essier solution would be to use an external mailing service so that you they can handle that for you
I often made the experience, that mails that are directly getting sent by PHP are recognized as SPAM...
my approach is now, to always use a SMTP-Server for sending those emails...
this post could help you!

Spam Filter in Contact Form

With an HTML contact form such as
HTML contact form
<h1>Contact Form</h1>
<p>Please fill in the following details and click on SEND.</p>
<form action="mail_contact.php" method="POST">
<p>Name<br> <input type="text" name="name"></p>
<p>Email Address<br> <input type="email" name="email"></p>
<p>Message<br><textarea name="message" rows="6" cols="50"></textarea><br>
<input type="submit" value="Send"><input type="reset" value="Clear"></p>
</form>
I am trying to stop spam messages getting through by checking for certain words being used in the message.
I have a .txt file which has words I want to filter for such as
File: spamwords.txt
CAN-SPAM
SEO
keywords
Keywords
In the PHP coding I have
mail_contact.php
<?php
// Create Variables
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// Function to deal with errors
function died($error) {
echo 'We are very sorry, but there were error(s) found with the form you submitted.';
echo 'These errors appear below.<br><br>';
echo $error.'<br>';
echo 'Please press <b>back</b> and fix these errors.';
die();
}
// Validate email address
$error_message = "";
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error_message .= 'The email address you entered does not appear to be valid.<br>';
}
if(strlen($error_message) > 0) {
died($error_message);
}
// Prevent spammers from using contact form
//Create an array containing the words in the message
$MessageArray = explode(" ", $message);
//Get SPAM words from file and store them in an array
$SpamWords = file_get_contents('/spamwords.txt');
$SpamArray = explode("\r\n", $SpamWords);
//Cycle through all the words in the message
foreach($MessageArray as $word){
//Check the word for SPAM words, if it is don't send the email
if(in_array($word, $SpamArray)){
echo '<h1>Spam Guard</h1>';
echo '<p>Here in European Community, the Privacy and Electronic Communications Regulations 2003 cover the sending of email marketing. This legislation says that organisations must only send marketing emails to anyone if they have agreed to receive them, except where there is a clearly defined customer relationship.</p>';
echo '<p>It appears that you are attempting to send an unsolicited message (e.g. a marketing message).</p>';
echo '<p>We as an organisation do not send unsolicited messages and we request that you do the same for us.</p>';
echo '<p>If you are not attempting to send an unsolicited message, there may be an error in the system so please accept our apologies.</p>';
die();
}
}
//If we've made it to this point, our message doesn't contain any obvious SPAM words
// Formulate Email
$formcontent='Message: \n $message \n \n From: $name $email';
$recipient = << my email address >>;
$subject = 'Contact Form Message';
$mailheader = 'From: $name <$email> \r\n';
mail($recipient, $subject, $formcontent, $mailheader) or die('Error!');
echo 'Thank you for contacting us. We will be in touch with you very soon via your email address<br>' . $email;
?>
When I test this out with a message containing the word SEO for example SEO test message it should display the Spam Guard message to the visitor - hence the echo commands - and then not send the email to me, but it displays the thank you message and sends me the email.
Can anyone see where I have gone wrong as it has stumped me
[Additional Note]
I have been using a CAPTCHA mechanism but some still get through
Your explode function needs double quotes around its delimiter:
$SpamArray = explode("\r\n", $SpamWords);
With single quotes, explode will attempt to split on the \r\n literal.
Or you could use file() instead of filter_get_contents() which will return the file as an array, with each line per key. trim() each line that's returned and you have your resulting array:
$SpamArray = array_map("trim", file('/spamwords.txt'));
Eureka!!!
I had to take the forward slash out of $SpamWords = file_get_contents('/spamwords.txt');
mail_contact.php [Edited]
<?php
// Create Variables
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// Function to deal with errors
function died($error) {
echo 'We are very sorry, but there were error(s) found with the form you submitted.';
echo 'These errors appear below.<br><br>';
echo $error.'<br>';
echo 'Please press <b>back</b> and fix these errors.';
die();
}
// Validate email address
$error_message = "";
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error_message .= 'The email address you entered does not appear to be valid.<br>';
}
if(strlen($error_message) > 0) {
died($error_message);
}
// Prevent spammers from using contact form
//Create an array containing the words in the message
$MessageArray = explode(" ", $message);
//Get SPAM words from file and store them in an array
$SpamWords = file_get_contents('spamwords.txt');
$SpamArray = explode("\r\n", $SpamWords);
//Cycle through all the words in the message
foreach($MessageArray as $word){
//Check the word for SPAM words, if it is don't send the email
if(in_array($word, $SpamArray)){
echo '<h1>Spam Guard</h1>';
echo '<p>Here in European Community, the Privacy and Electronic Communications Regulations 2003 cover the sending of email marketing. This legislation says that organisations must only send marketing emails to anyone if they have agreed to receive them, except where there is a clearly defined customer relationship.</p>';
echo '<p>It appears that you are attempting to send an unsolicited message (e.g. a marketing message).</p>';
echo '<p>We as an organisation do not send unsolicited messages and we request that you do the same for us.</p>';
echo '<p>If you are not attempting to send an unsolicited message, there may be an error in the system so please accept our apologies.</p>';
die();
}
}
//If we've made it to this point, our message doesn't contain any obvious SPAM words
// Formulate Email
$formcontent='Message: \n $message \n \n From: $name $email';
$recipient = << my email address >>;
$subject = 'Contact Form Message';
$mailheader = 'From: $name <$email> \r\n';
mail($recipient, $subject, $formcontent, $mailheader) or die('Error!');
echo 'Thank you for contacting us. We will be in touch with you very soon via your email address<br>' . $email;
?>
Check this out, it will be useful
Spam Word Blocker PHP
You can generate random variable name and random value for hidden input and save in session. After form submitting you can check they in $_REQUEST var. Also you can use interval between form rendering and submitting. Don't try to check spam words just protect from bots and don't use simple captcha.

My Script APPEARS not to be working, suggest to use SMTP?

first of all, I am learning PHP and I am at an elementary level, (sorry). I have a script that send me an email once the form it filled in. The form is located on another page, this is the page that does all the magic. For SOME REASON, this code does not work, I do not get an emails at all. As I missing something!
Thank you
<?php
if(!$_POST) exit;
// Verifico email.
function isEmail($email) {
return(preg_match("/^[-_.[:alnum:]]+#((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
}
if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$comments = $_POST['comments'];
$verify = $_POST['verify'];
if(trim($name) == '') {
echo '<div class="error_message">Attention! You must enter your name.</div>';
exit();
} else if(trim($email) == '') {
echo '<div class="error_message">Attention! Please enter a valid email address.</div>';
exit();
} else if(!isEmail($email)) {
echo '<div class="error_message">Attention! You have enter an invalid e-mail address, try again.</div>';
exit();
}
if(trim($subject) == '') {
echo '<div class="error_message">Attention! Please enter a subject.</div>';
exit();
} else if(trim($comments) == '') {
echo '<div class="error_message">Attention! Please enter your message.</div>';
exit();
} else if(!isset($verify) || trim($verify) == '') {
echo '<div class="error_message">Attention! Please enter the verification number.</div>';
exit();
} else if(trim($verify) != '4') {
echo '<div class="error_message">Attention! The verification number you entered is incorrect.</div>';
exit();
}
if(get_magic_quotes_gpc()) {
$comments = stripslashes($comments);
}
// Configuracion.
$address = "abc#xyz.com";
$addressrrhh = "abc#xyz.com";
$e_subject = 'You\'ve been contacted by ' . $name . '.';
// Campos del form ampliables.
$e_body = "You have been contacted from JACK contact form by $name with regards to $subject, their additional message is as follows." . PHP_EOL . PHP_EOL;
$e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;
$e_reply = "You can contact $name via email, $email";
$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
$headers = "From: $email" . PHP_EOL;
$headers = "BCC: $addressrrhh" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
if(mail($address, $e_subject, $msg, $headers)) {
// Mensaje envio OK
echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h1>Email Sent Successfully.</h1>";
echo "<p>Thank you <strong>$name</strong>, your message has been submitted.</p>";
echo "</div>";
echo "</fieldset>";
} else {
echo 'ERROR!';
}
?>
Please have a look at http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods and http://php.net/manual/de/function.mail.php first
First thing first
Do you have errors when you submit in your webserver error log ?
Is your mail sent ? (Check your mail log)
If so, is it in your spam folder ?
About your mail marked directly as spam
Things "changed" a little bit, and you can't just send an email without setting the "fifth" parameters or your mail will go directly to spam boxes.
From http://php.net/manual/en/function.mail.php
The additional_parameters parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail, as defined by the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.
The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.
Also, i'm suggestion you the very good phpmailer
Usage exemple : http://phpmailer.worxware.com/index.php?pg=examplebmail
Hope it helps
I think that using SMTP is better than something else. If you encounter problems with the mail() function, maybe you take a look at PEAR: pear.php.net
Post is something completely different. Its not like the dutch word post which means mail :D
$_POST is a variable that stores all values a post form sends. so for example: a form with the method POST has 1 input text field with the name "foo". After you type in: "bar" in that field and submit the field a $_POST array is created where $_POST["foo"] has the value "bar"
Maybe you read something about not using php's on mail() function and better use SMTP? That makes a little bit more sense...
Good luck

Categories