email - PHP mail function not working based on the body of the message


so on my server I tried running:

mail('', 'asdf', 'asklfdjksalfdsdaf I know I I know I');

and PHP sent the mail perfectly....but then when I changed the message to

mail('', 'asdf', 'hahahahaa');

it did NOT send the email to me....

what can possibly cause this? the only thing that's different is the message body...I am completely baffled...

2 Answers: 

Here's the way I send messages with php and avoid sending to spam folder:


$to = "";
$subject = "Test Email";
$message = "Test Email";

// normal headers
$num = md5(time()); 
$headers  = "From: Mailer <>\r\n";
$headers  .= "MIME-Version: 1.0\r\n";
$headers  .= "Content-Type: multipart/mixed; ";
$headers  .= "boundary=".$num."\r\n";
$headers  .= "--$num\r\n";

// This two steps to help avoid spam   

$headers .= "Message-ID: <".time()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
$headers .= "X-Mailer: PHP v".phpversion()."\r\n";         

// With message

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "".$message."\n";
$headers .= "--".$num."\n"; 

@mail($to, $subject, $message, $headers);


You should check your spam filter. It is possible that it is catching the message as being too short or not having enough discernible words, or any one of the other hundred things they'll check for.

If it is the spam filter, another thing that will help is adding different headers to help validate the email. Sometimes simply adding a realistic FROM in the headers can allow it through a spam filter. There's a default FROM set, usually in your php.ini but if it's some system generated name then filters can flag it.

mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

More Articles

php - Is it possible to tell the names of the $_GET variables the page is waiting for?

Hello I have a question about PHP $_POST and $_GET.Let's say I have a web page that is expecting $_GET variables.Are the variable names anonymous?Let's say index.php has the script ofif( isset( $_GET['somevariale'] ) ){ rest of the code}Is it possible for anyone to find out the name of the $_GET va

android - the app falls when i select a user from a SQLITE list and pass the ID to another activity

i have a minor problem here, the app i created makes the user adds contacts details of his own and can call them again by pressing on them from the listview and thier data should appear on the new activity to edit or delete themthe problem is that the app crashes when i select a contact....where did

scikit learn - How to reuse pickled objects in python?

I have pickled some of the objects so that I can reuse them later. For example, I pickled three different gradient boosting regressors that I wanted reuse later. However, when I tried to use transform method for the regressor, python complained that it needs to be fitted first. Below is the code:mod

r - How to look back a few rows higher to see if a condition is satisfied and then replace a cell accordingly

I have a dataframe whereby if a condition is satisfied, it looks a couple rows above to find a specific row with another string and replaces itself with that entire cell which had the string.Here is an Example:If "test" is detected in the type column, it looks up to 3 rows above for a row which cont

php - How can I protect our site from email subscription spamming?

Our site has email input field for service launch notification. We do not use this for newsletters, only for notification. So I tested our site for basic vulnerabilities and found out that our email list fills up with spam email addresses.I have this kind of php code to prevent spamming but still SO

apache spark - Scala - How to iterate over tuples on RDD?

I have an RDD that contains tuples like this (A, List(2,5,6,7)) (B, List(2,8,9,10))and I would like to get the index of the first element where a specific condition between value and index holds. So far I have tried this on a single tuple test and it works fine:test._2.zipWithIndex.indexWhere

Dose google play count insalls out of itself downloads?

I recently published my app in google play . The question is how google play show counts ?1 - All device that have google play installed and my apps too , total count of my apps install will show in play store .2 - Just all downloads that directly are downloaded from google play will be count .

c# - Regular expression to match a string that contains only numbers, not letters

My code is currently using the following Regex expression which matches on numbers:Regex numberExpression = new Regex(@"(?<Number>\d+)");This current works fine for input strings like "1", "100", "1a", "a1", etc....But I want to change it so it does NOT match when the input string contains a l

cookies - PHP Unique Computer ID

Is it possible for php(or javascript in the worst case) to create a unique id for a user that is not cookie or ip dependant. I have seen on that on each city the count only goes up once a day(it has a unique id for everyone i think) and even if I delete my cookies and refresh ip it st

javascript - jQuery .load: any way to load the same page when page is refreshed

So I have a website that loads pages to a container div:function goto(addr) { $("#content").load(addr);}and a link that executes it<a href="#" id="aboutus" onclick="goto('page/aboutus.php');">About us</a>My problem is that whenever the page is refreshed, the loaded content resets to t