This question already has answers here:
Gmail and Hotmail marked as spam
(5 answers)
Closed 8 years ago.
My emails that are send by mail() are getting directly into the spam box, tested with GMAIL and HOTMAIL.
So:
I have dedicated server
My server ip is not listed on any blacklists
This is my code:
function send_email($recipient, $sender, $subject, $email_body){
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$sender;
mail($recipient,$subject,$email_body,$headers);
}
$from = 'info#domain.com';
$subject = 'subject';
$email_body = '<h1 style="text-align:center;">Title</h1><p>Message</p>';
send_email($userbday['email'], $from, $subject, $email_body);
Any thoughts?
Try to setup an SPF record for your domain.
Also
Email is serious business.
Try transactional email service providers
It may be that your email looks exactly as spam. It sometimes happens...
All my applications sends email - depending on how the client prepare the email templates - some are treated as spam almost instantly, some not.
Setting SPF Record can help, but also check (and use) some blacklist emails for your own good - like people who dont want to receive your emila should never be bothered again as they can trigger your server to be in the black lists (for example spamcop).
Related
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
How do I prevent mails sent through PHP mail() from going to spam? [duplicate]
(6 answers)
Closed 3 years ago.
So a company I am helping out has outlook for their mail. Unfortunately, outlook seems to be very inflexible on how I can set up emails. I have added multiple domains to the outlook admin center for our multiple different sites. However, it will not let me create anything useful with the new domains.
For instance, we have "information#ourMainDomain.com" set up as an account.
I tried to create an alias on this account for "information#aSecondaryDomain.com" but then outlook gives me an error saying "information#ourMainDomain.com" already exists. Evidently you cannot use the same username even with different domains.
Fine. So i tried to create a shared mailbox - same issue. information#aSecondaryDomain.com is not allowed, because information#ourMainDomain.com exists... getting frustrating now!
So, after experimenting, trying everything, and spending 2 hours on the phone with outlook support that got me no where, i opted for my own route:
I created a Distribution Group called information#aSecondaryDomain.com, told this that senders outside the organization can send to it, added all the people that need to be involved, and gave them all send access.
This allows us to send emails as info#aSecondaryDomain.com
It allows us to recieve them here as well.
Also, i can send from outside the organization, ie from my gmail i can send to this account and it comes through, Great!
The problem is when i use php for a contact form, it WILL NOT send to the distribution group. It is not going to junk that i can see, and mail trace doesnt show it ever coming in at all. If i change the send to address of mail function to one of our main emails with the organization it comes through. If i change it to send to my gmail it comes through. As soon as i set it to the address of the distribution group, it will not come through. I see no errors on the php, it thinks it sent... but it never does.
Does anyone have an ideas? Or has anyone done this before?
The code in question is very simple...
<?
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$subject = $_REQUEST["subject"];
$msg = $_REQUEST["msg"];
$to = "information#aSecondaryDomain.org";
if (isset($email) && isset($name) && isset($msg)) {
$email_subject = "$name sent you a message";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$name." <".$to.">\r\n"."Reply-To: ".$to."\r\n" ;
$msg = "From: $name<br/> Email: $email <br/> Subject: $subject <br/> Message: $msg";
$mail = mail($to, $email_subject, $msg, $headers);
if($mail)
{
echo 'success';
}
else
{
echo 'failed';
}
}
?>
EDIT: I have no tried PHPMailer... same reuslt - it will send to my regular work address, and my personal, but not to the distribution group.
I'm trying to send e-mail using PHP. I took a piece of code that I have been using earlier, but it doesn't work anymore. I figure out the problem was coming from the subject.
When my subject is "test", the mail is sent, but when my subject is anything else with for example capital letters, like "Test", it doesn't work. I'm pretty sure this is a quick fix, but I can't find the answer.
Here is my code.
In index.php
$subject= 'test';
$message = implode("\n" , $_SESSION['data']);
mail_html($subject, $message, $email);
In functions.php
function mail_html ( string $subject, string $message, string $receiver) {
$headers = 'From: Template <me#me.com>' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8';
mail($receiver, $subject, $message, $headers);
}
Thank you everyone for helping me. I feel stupid getting blocked by things like that.
Sending E-Mails is a very difficult process. So you can't send E-Mails so easy from your Computer or Server if you don't have alle the common SPAM prevention mechanisms enabled.
So when you don't a Reverse-DNS entry and you send an Email with "Test" you should not wonder if the emails can't send to the other site. So Take a look at the SPF-System, Reverse-DNS and generic names for servers (not working for some providers). Then you can send some E-Mails.
To find some problems check your mail log /var/log/mail.log.
When you try to prevent that problems use an SMTP account from your provider and send that E-Mails over SMTP.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I have made a password recovery option in my website using php mail function. It works with gmail and yahoo but when the email is hotmail it does not works, I tried many time. When I tried with my companies email (outlook) nothing happens. It only works with gmail and yahoo. What can be wrong with it. the code I am using is her below:
$email= "customer_email_address";
$head = "From: \"Pizza Hut Pakistan\" <no-reply#pizzahut.com.pk>\n";
$head .= "X-Mailer: RegFormPHP\n";
$head .= "Priority: urgent\n";
$head .= "Importance: High\n";
$head .= "Content-Language: en-us\n";
$head .= "Reply-To: <no-reply#pizzahut.com.pk>\n";
$head .= "Organization: \"Pizza Hut Pakistan\"\n";
$head .= "Content-Type: text/html\r\n";
$msg = 'Click the link below to proceed <br><br>';
$msg .= 'http://'.$_SERVER['HTTP_HOST'].'/root_folder/forgotlink.php?id='.$unique_code_of_user;
mail($email, "website account password recovery", $msg, $head);
every thing is cool with gmail and yahoo. but..... nothing works with others....
Thanks
Hotmail is probably rejecting your emails thinking it's spam.
Hotmail is known to be a PITA when it comes to emails... You can check if you have correct DKIM and SPF parameters, see if your server isn't blacklisted, or better yet, use a mailing provider like MailChimp, SendGrid or similar to be sure your emails are sended in best conditions.
You can try class.phpmailer.php. It works for Yahoo, Hotmail, GMail,
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.
I have a web site that provides daily real estate updates. Users register, and we send them an email every day. However, Gmail is marking all of our emails as spam. What should we be looking out for?
Spam emails are based on Server, domain and blacklist history.
This is controlled by the Service Provider there is not a lot you can do to be honest.
The best thing is is to add the sender email to your safe list i.e. no-reply#example.com
Due to the simplicity of PHP, it is very easy to send a mail through
mail(), however there is 99% of chances that you are doing it wrong.
You need to follow the right guidelines to use mail(). My recommendation is use a third party mail service like Mandrill
If you still choose to go ahead with php mail(), please follow the below guidelines, which will help you to certain extend.
Set the right Headers:
$headers .= 'From: YourLogoName info#domain.com' . "\r\n" ;
$headers .= 'Reply-To: '. $to . "\r\n" ;
$headers .='X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$to = to#hello.com;
$subject = subject ;
$body = "<div> Email body goes here.. </div>";
mail($to, $subject, $body,$headers);
Message Sender Domain and Server Domain Should Match
Spammers are notorious for sending emails from one server and trying to make the recipient believe that it came from somewhere else. So if you are sending an email from sender#yourdomain.com, it is a good idea the the script reside on example.com.
The Server is not Blacklisted
When a server is blacklisted, it means that that server has identified as one that has been sending a lot of spam. This results in recipient mail servers rejecting or filtering any mail that is received from that server.
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.
I know that there are many similar questions on this site, but none of them helped me.
I have the following PHP code:
<?php
$to = "mymail#inbox.com";
$from = "no-reply#heygee.com";
$subject = "Confirm your registration!";
$message = "Please follow this link to confirm your registration: www.bit.ly/32106";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: HeyGee! <no-reply#heygee.com>" . "\r\n" .
"Reply-To: mymail#inbox.com" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$ok = #mail($to, $subject, $message, $headers, "-f " . $from);
?>
Let's say mymail#inbox.com is my test e-mail. Whenever I send the mail to my address, I always receive the mail in my Spam folder. Why is that? Are there any corrections or tricks to be made to prevent the mail from arriving in Spam?
Thanks.
The reason why your mail is being sent to Spam folder is either because of the content of your email or that the receiving side is not able to verify if the email actually came from the stated domain in the from address, i.e., if the sender (you) are authorized to send email on behalf of heygee.com.
Content part is easy to correct. You need to avoid bad grammar, ambiguous links (e.g links which say google.com but point to example.com), etc. Your message should be well worded (exclude those words frequently found in spam mails), and preferably include an unsubscribe link as well (if sent to a mailing list).
Now comes the second and difficult part. The domain that you are writing in your from address should be the same domain from which you are executing this mail script or should be authorized by this domain's TXT records to send mail on its behalf. The simplest way to go about this would be (provided you have DNS access to the sending domain name) to add a TXT SPF record permitting the IP of the server your script resides on to send mail on its behalf.
Example SPF record:
"v=spf1 ip6:1080::8:800:200C:417A/96 -all"
The above record means Allow any IPv6 address between 1080::8:800:0000:0000 and 1080::8:800:FFFF:FFFF.
Checkout:
SPF (Wikipedia)
Also, you may have a look here http://www.openspf.org/
Now if you don't have DNS access, then simply change the domain name of the from address to the domain name of the server and it should fix it.
Hope it helps.
This is not related to your programming by itself. Filtering e-mail as spam is done on the client side and there is nothing you can change about that (if it were, millions of spammers would be doing it)
The problem you have is that your e-mail looks like spam. Try to write a better e-mail, with a body longer than 1 line. I would also remove the exclamation mark from the subject; that's also something that makes it look like spam.
If your spam detection system gives you detailed information on why it was labeled as spam (SpamAssassin can do that depending on how it is configured), then use that information to fix the e-mail that you send.