Mail is not going directly into inbox - php

This is my code . When i send an email from an id to its same id then email goes to junk . Unable to identify that what is the problem in this code . For example i send an email like this
From = abc#yahoo.com
To = abc#yahoo.com
Then it goes directly to junk .
<?php
$name=$_POST['fName'];
$yemail = $_POST['yEmail'];
$femail=$_POST['fEmail'];
$message=$_POST['message'];
$from=$yemail;
$to=$femail;
$subject="Invitation for you";
$mailBody ="<table width='628' border='0'>
<tr><td align='left' valign='middle'><p><br><br>Hello,<br><br>This email is a notification to let you know that your friend has invited you to <br>visit this link <a href=www.heed-association.org>Heed Association.</a><br><br> Your friend is using this to help people living in Pakistan by donating some money.<br><br>So your can also contribute in the areas of Health, Education, Environment and Sustainable Development<br> in the earthquake affected areas of Kashmir to improve living conditions and alleviate community distress<br><br><hr><br><br><strong>Regards<br><br>Heed Association</p></td></tr></table>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: <'.$yemail.'>' . "\r\n";
if (mail($to, $subject, $mailBody, $headers)) {
echo "<script language='javascript'>
window.location = 'index.php';
</script>";
} else {
echo "<script language='javascript'>
window.location = 'tell_a_form.php';
</script>";
}
?>

I would say check your spam filters. As silly as it sounds, add the email to the safe senders list. There doesn't appear to be anything really funky going on in your code.

It's probably an oversensitive spam filter. A lot of programs can detect if the email wasn't actually sent from the email address listed in the "from" column. Usually the way to circumvent this is to have the email come from "no-reply#yourdomain.com".

Related

PHP Email wont send to custom email addresses

I have a script to send a customer an email. We have just noticed that the emails are only being sent to email addresses that end normally like : #gmail.com, #yahoo.com, #Hotmail.com, etc. Whenever we encounter a custom email address like **#platinumpets.com or *#landsberg.com the email address will not ever be received. I can confirm that the server is sending out the email, the user is just never receiving it. We have checked all spam folders and done various Google searches but I have not found any issues this similar to ours. Any ideas? Here is the code :
<?PHP
$subject = "Alert";
$mailheader.= "From: " . "Smartphone Pet Tag Team <support#smartphonepettag.com>\n";
$mailheader.= "X-Sender: " . "support#smartphonepettag.com\n";
$mailheader.= "Return-Path: " . "support#smartphonepettag.com\n";
$mailheader .= "Bcc: support#smartphonepettag.com";
$body .= "Dear " . $ownername . ", \n\n";
$body .= "" . $petname . "'s Smartphone Pet Tag has just been scanned.\n\n";
$body .= "Click here to Login :\n";
$body .= "http://www.smartphonepettag.com\n";
$body .= "********************\n\n";
// $body .= "Scan detected at " . $
//$body .= "Your pets id tag was scanned at the following date and time: " . $datetime; . ", \n";
// $body .= "To stop receive automated alerts click here: \n";
// $body .= 'http://www.smartphonepettag.com/id/alert.php';
// $body .= "and provide your username and password to remove these alerts.
$body .= "Regards,";
$body .= " \n\n";
$body .= "Smartphone Pet Tag Team";
$body .= " \n\n";
$body .= "Keeping Pets Safe and Found";
mail($email_to, $subject, $body, $mailheader ) or die ("Mail could not be sent.");
//end email alert
}
//$id=$_GET["id"];;
if (!$id) {
echo 'You have not entered an ID number. Please go back and try again.';
exit;
}
if ($id=="id=app") {
header("Location: http://www.smartphonepettag.com/id/app.php");
exit;
}
header("Location: http://www.smartphonepettag.com/id/profile.php?id=$id");
?>
I'm not sure where you get &email_to from but this doesn't seem to be the problem anyway.
For me it seems that this is not a problem with PHP. PHP built-in mail functions usually don't use whitelists or anything like this and in your code I can't see any problems relating to what you describe.
But PHP uses the local mailserver installed on your server system. So maybe it's something strange configured on your mail server? You may try sending mails directly via SMTP to find out if the will be sent successful. Depending on your mailserver you may also check the "outbox" (if you not already did).
Otherwise it is definitely a problem with the receiver. PHP generated eMails often look like spam for spam filters. If your are sure that the mail is sent but the problem is not related to the spam filter you don't really have a chance to do anything. You can't change the behaviour of foreign mail servers in this case.
But for me it seems very likely that it's a spam-problem.

Email code not working

I'm not sure what happen to my email code as i'm comparing with all the code i able to find online ... when i using localhost, it's work no problem.. and it having the txt file appear in mailoutput folder in xampp.
but when i request my friend to help host to web service.. it cannot work anymore for the code :(
below is my code. (modified from online source)
$subject = "Thanks for Registering." ;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From : email' . "\r\n";
$message = "<html><body>
<p> Thank you to register with Lecture Public Room Book Portal </p>
<p> </p>
<p> In order to activate your account please click the link below:</p>
<p> <a href='link'>Verify Account</a> </p>
<p></p>
<p>Or you may go to the verification page using below link and paste in the verification code. Your verification code is $ver_code.</p>
<p> <a href='link'> Verify page </a> </p>
<p> </p>
<p> Please do not reply to this email has the mailbox isn't monitored.</p>
<p> </p>
<p> </p>
<p><center> - The Webmaster () - </center> </p>
</body></html>";
if(mail($email, $subject, $message, $headers))
{
$_SESSION['type'] = "User";
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Successful register. Please check your email for activate account.')
window.location.href='index.php?user=$username#verify-slide';
</SCRIPT>");
exit();
}
else
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Please try again.')
window.location.href='index.php?signup-slide';
</SCRIPT>");
exit();
}
wish someone could please help me :(
Maybe your hoster restricted access to php mail function. Email him about it. If so you can use Mandrill app.
Please check your error log if it returns some errors.
$headers .= 'From : email' . "\r\n";
Put your email in the email field ( preferably from the same domain email address )
A few bullet points (Assuming that mail() returns true and there are no errors in the error log) :
Does the sender address ("From") belong to a domain on your server? If not, make it so.
Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a remote possibility with shared hosting.
Are mails filtered by a spam filter? Open an account with a freemailer that has a spam folder and find out. Also, try sending mail to an address without a spam filter.
Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)
If you have access to log files, check those, of course, as suggested above.
Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.
from here
In your current page email recipient is not set like this:
$subject = "Thanks for Registering." ;
$from = "admin#abc.com";
$email = "someone#gmail.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From :' . $from. "\r\n";

PHP Web Form Not Sending To Gmail Email

I have a php form that I made and when someone fills out the form it works fine with all other email accounts (yahoo, hotmail, #mydomain.com, etc) but when it comes to sending the email to a gmail user, the email never comes through, not even in the spam box.
$from = $email;
//Testing Below
//$headers = 'From:noreply#mydomainname.com' . "\r\n";
$headers .= "From: $from \n";
$headers .= " MIME-Version: 1.0\r\n ";
$headers .= " Content-Type: text/html; charset=ISO-8859-1\r\n ";
//Mail The Message
mail($to, $subject, $message, $headers);
The code above will not send to gmail but will work for all other email accounts. This one (below) will work for gmail but of course then I don't have the option of html in the email.
$headers = 'From:noreply#mydomainname.com' . "\r\n";
//$headers .= "From: $from \n";
//$headers .= " MIME-Version: 1.0\r\n ";
//$headers .= " Content-Type: text/html; charset=ISO-8859-1\r\n ";
//Mail The Message
mail($to, $subject, $message, $headers);
So basically when I add the MIME and Content type to the headers variable it wont send to a gmail account.
Thanks in advance!
I have replied a question not too long ago related to this. It might have to do with the gmail's email filtering, maybe you are getting too high spam score so it's not even getting into the spam folder, this could be caused by not having correct dns configuration / keys and trying to use html at the same time.
I leave a link to the other answer (It's quite long, and not as easy as you would imagine xD):
PHP and Gmail spam filter
Hope it helps you.
You are not using a proper concatenation operator:
Change your From line to:
$headers .= "From: ".$from;

PHP mail() -f parameter is NOT working

I've researched this intensely. Here, at Stack Overflow, I've figured out that one needs to use an -f parameter with the php mail() function, if one wants undeliverable mail to bounce back. Following is my script (as it stands now):
//Send Confirmation email. Following are the variables for the email
// mail function best practices: http://collaborate.extension.org/wiki/Best_Practices_Using_the_PHP_mail_Function
$sendto = $email; // this is the email address collected from the foreach routine.
$e_subject = stripslashes($subject); // Subject
//$message = "<html>" . stripslashes($body) . "</html>";
$message = "
<html>
<body>
<p>Hello " . stripslashes($fName) . ":</p>
<div>" . stripslashes($body) . "</div>
</body>
</html>
";
// Always set content-type when sending HTML email
$header = "MIME-Version: 1.0" . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";;
// extract user domain so you can set up X-Mailer
$u_domain=substr(strrchr($user_email, '#'), 1);
$dom_array = explode(".",$u_domain);
$user_domain = $dom_array[0];
$header .= "X-Mailer: ". $user_domain ."\r\n";
$header .= "X-Sender-IP: {$_SERVER['REMOTE_ADDR']}\r\n";
$header .= "X-Originating-IP: [".getenv("REMOTE_ADDR")."]\r\n";
$header .= "From: " . $user_email . "\r\n";
$header .= "Sender: ". $user_email . "\r\n";
// The "envelope sender" is the address listed in the "Return-Path:" header - and controls where the email is sent to in the event that a recipient address bounces. http://collaborate.extension.org/wiki/Best_Practices_Using_the_PHP_mail_Function
$header .= "Return-Path:" . $user_email . "\r\n";
$header .= "Reply-To:" . $user_email . "\r\n";
$bounceTo = "-f". $user_email;
// Collect variables from above and insert into the mail() function.
mail($sendto, $e_subject, $message, $header,$bounceTo);
You'll notice a lot of commenting - I'm just trying to figure this out. My mail() sends wonderfully. The mail is coming into my inbox with formatting as it should be. But... the $bounceTo variable ("-f" . $user_email) is not working. I've intentionally mailed to 3 known inactive addresses, and I'm not getting any bounce backs.
All the header settings in the above code are in place because I've learned that these may affect bounce backs. I'm totally willing to get rid of un-necessary headers and add what is necessary. But... at this point the script seems to be a mess -which is not producing bounce backs.
Any suggestions are welcome.
Thanks Much:
Pavilion
Have you looked at the comment posted at http://www.php.net/manual/en/function.mail.php#107321. That might lead you in the right direction.
This thread explaining bounced mail in php might be of benefit to you. I personally have never had to use the -f parameter to handle bounced emails.
Overriding the bounce address with -f is not allowed on all servers, especially if you are on a shared hosting server this is often not possible. In this case, it's often better not to use the very limited mail() function but use a smtp library like phpmailer or swiftmailer instead.
Btw: you don't have to send mails to an inactive address to check your bounce address. Send them to an active account, in the message source look for the "Return-Path" header, this is the bounce address.

sending mail with link and parameter in PHP

I have a strange issue with sending a mail with php, here is my code:
$link = "http://www.somelink/verify.php?id=".$uniqID;
$message ="<html><head></head><body><p>Full Name:".$data[0]." ".$data[1]."</p>";
$message .="<p>Flight Number: ".$data[4]."</p>";
$message .="<p>The Ride: ".$curPlace." to ".$data[5]."</p>";
$message .="<p>Number of Passengers: ".$data[3]."</p>";
$message .="<p>Date:".$data[6]." time:".$data[7]."</p>";
$message .="<p>The price: ".$data[8]."</p>";
$message .="<p>To verify the reservation press this link</p></body></html>";
$headers = 'From: my#email.com' . "\r\n" .'Reply-To: some#email.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "Sensitivity: Personal"."\r\n";
$sent=mail($data[2],"Taxi Reservation",$message, $headers);
if($sent){
echo "Message was sent to ".$data[2];
}
else{
echo "Message was not sent";
}
The problem is with Gmail.If I send it as is, I get the success message, but get nothing in my gmail, but do get in another not gmail account.
BUT!
If I delete a tag from this line:
$message .="<p>To verify the reservation press this link</p></body></html>";
I do get the message in Gmail.So I can't understand what's the problem.
What can couse this problem?
Thank you for your help.
If your email is not arriving at Gmail, but the same code sending the same email is arriving at a different account, I suspect that the problem is that Gmail are seeing your email and classifying it as spam - have you checked to see if it's gone into your spam folder instead of your inbox?
Gmail has a set of rules to identify what they think is spam - presumably, including the link is enough to push your email into the spam category.

Categories