I'm using Amazon SES to send bulk emails to my users. Some emails is marked as spam though. What can I do mitigate the spam marking?
code in PHP:
$ses = new AmazonSES();
$destination = array();
$destination['ToAddresses'] = $email;
$message = array();
$message['Subject.Data'] = "Domains: $contactsName have made a descision";
$message['Body.Text.Data'] = '';
$message['Body.Html.Data'] = " Hi $firstName!
</br>
</br>
$contactsName have made a descision regarding $title at $link
</br>
</br>
Sincerely,
</br>
</br>
The Domain Team";
$message['Body.Html.Charset'] = 'utf-8';
$response = $ses->send_email('info#domain.com', $destination, $message);
There are many questions around this which will affect your spam reputation, but some quick ones:
How many users are you sending to (approximately)?
Do you always send emails to these users from this IP address?
Have your users opted-in to receive emails? Do they have an ongoing email relationship with you? Do they normally read emails that you send to them, or just delete them without looking?
Is your HTML valid? (From the above example, it appears than no - it should be <br/> not </br>.)
These are a few quick questions. The best quick advice I can give you is to make sure the users are opting-in, and encourage them to add you to their friend list. Try to send every email communication between you and them from Amazon SES.
I am not familiar with Amazon SES, but I will have an attempt at this one.
There is an interesting discussion, specifically dealing with email sent through Amazon SES and getting marked as Spam here - AWS Forum: "Email marked as spam CLOUDMARK"
Along with the points raised there, a couple of suggestions:
Always include a Text version of the content, some spam filters may interpret HTML-only emails as more likely to be spam (which they often are), plus some users may only have text-based email clients (some mobile users, etc.)
Check your spelling. Incorrect spelling is normally a dead giveaway for spam emails, and may result in people manually marking emails as spam without looking very closely.
(If possible.) Add a "From" Name. Again, if the email comes from a plain email address, rather than a Human-readable one which is appropriate to your message, it is more likely to look like spam (either to a filter or to a user).
Here is a suggested amended code (corrected spelling and HTML markup):
<?php
$ses = new AmazonSES();
$destination = array();
$destination['ToAddresses'] = $email;
$message = array();
$message['Subject.Data'] = "Domains: $contactsName have made a decision";
$message['Subject.Charset'] = 'UTF-8';
/* NOTE: Lines are broken for readability only */
$body = "Hi $firstName!<br>".
"<br>".
"$contactsName have made a decision regarding $title at $link<br>".
"<br>".
"Sincerely,<br>".
"<br>".
"The Domain Team";
$message['Body.Text.Data'] = str_replace( '<br>' , "\n" , $body );
$message['Body.Html.Data'] = $body;
$message['Body.Html.Charset'] = 'UTF-8';
$response = $ses->send_email('info#domain.com', $destination, $message);
Related
UPDATE
I was able to get the hosting info from my client and I contacted support, apparently there's an issue with the hosts mail function at the moment and they are working on a resolution. Will wait to see if that's the cause of this problem and will report back.
END UPDATE
I am trying to set up a simple contact form that will send an email. I have the form action set to the below PHP file.
The email gets sent, but the user experience ends with a 500 error instead of sending the user to the confirmation page.
If I comment out the mail() part, then the form redirects the user to the confirmation page successfully, but of course no email gets sent.
The website is hosted on GoDaddy, and I don't have access to the hosting account, though I can try to get it if I need it.
Here's the PHP code:
<?php
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['CITY'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$email = $_POST['email'];
$howdidyouhear = $_POST['hear_about'];
$notifyshow = $_POST['notify_shows'];
$notifyonline = $_POST['notify_online'];
$interest_jewelry = $_POST['Interest_jewelry'];
$interest_prints = $_POST['interest_prints'];
$interest_folkart = $_POST['interest_folkart'];
$interest_indian = $_POST['interest_indian'];
$interest_closeouts = $_POST['interest_closeouts'];
$interest_other = $_POST['interest_other'];
$interest_other_text = $_POST['interest_other_text'];
$spamvalid = $_POST['validate'];
$honeypot = $_POST['website'];
//Spammer Handling
if ($honeypot!=null){echo 'You have been flagged as a spammer, please go away!'; exit;}
if ($spamvalid != '357'){
echo "
<script>
function goBack() {
window.history.back()
}
</script>
You didn't enter the correct number at the bottom of the form. Please try again.<br><button onclick='goBack()'>Go Back</button>";
exit;
}
//START EMAIL
//Body
$mailbody="Name: {$name}\n\nAddress: {$address}\n\nCity: {$city}\n\nState: {$state}\n\nZip: {$zip}\n\nEmail: {$email}\n\nHow did you hear about us?: {$howdidyouhear}\n\nWould you like to be notified when we will be doing a show in your area?: {$notifyshow}\n\nWould you like to receive email notifications of special sales and online events?: {$notifyonline}\n\nWhat brought you to mishuganah.com?: {$interest_jewelry} {$interest_prints} {$interest_folkart} {$interest_indian} {$interest_closeouts} {$interest_other}: {$interest_other_text}\n\n";
//Send Email
mail('matt.rodela#gmail.com','New submission from Mishuganah.com', $mailbody, "From:{$email}\r\n" );
header("Location: http://".$_SERVER["HTTP_HOST"]."/mailing_list/confirmation_page.htm");
?>
I am a relative novice with PHP, so please explain your solutions fully. Thanks!
Use phpMailer instead of php mail() function below you will find reasons not to use built in php mail function
In some cases, mails send via PHP mail() did not receive the recipients although it was send by WB without any error message. The most common reasons for that issue are listed below.
wrong format of mail header or content (e.g. differences in line break between Windows/Unix)
sendmail not installed or configured on your server (php.ini)
the mail provider of the recipeint does not allow mails send by PHP mail(); common spam protection
Errors in the format of header or content can cause that mails are treated as SPAM. In the best case, such mails are transfered to the spam folder of your recipient inbox or send back to the sender. In the worst case, such mails are deleted without any comment. If sendmail is not installed or not configured, no mails can be send at all.
It is common practice by free mail provider such as GMX, to reject mails send via the PHP function mail(). Very often such mails are deleted without any information of the recipient.
So it turns out it was an issue on GoDaddy's end and it has been resolved. The form is working now. Apparently there was nothing wrong with the code.
Thanks for the suggestions folks, I learned some stuff (going to sanatize and filter my inputs now).
My use of Pear to relay one of our site's users ('sender') email to another user ('recipient') fails because the recipient user always receives the mail in their spam folder. For the explanation below, our website is called "oursite.com."
I have narrowed this down after 2 solid days of lots of experimenting to the "From" part of the 'headers' as follows (for the sake of this example, my name is Sam Hambone and I have no idea how the 'From:' in the title of the email is grabbing my name and using it as described below):
$senderEmail = "IamTheSender#gmail.com";
// this version of the 'from' variable makes the 'From' in the email's title
// look correct, like this: "IamTheSender#gmail.com (IamTheSender#gmail.com)"
// but when the recipient gets the mail, it will ALWAYS go into the 'junk'
// or 'spam' email folder of the recipient's inbox. NOTE: using angle brackets
// instead of parentheses here changes nothing.
$from = $senderEmail . " (" . $senderEmail . ")";
// this second version of 'from' makes the mail arrive correctly
// in the recipient's Inbox and not in their spam/junk folder, but
// the "From:" line in the email's title looks like this:
// "Sam Hambone (IamTheSender#gmail.com)"
$from = $senderEmail;
EDIT: here is what the email's title and headers look like using the 1st version of 'from' above -- in this case I sent an email to myself as the recipient:
'Sender has a question for you, Mr. Recipient!'
Sam Hambone (IamTheSender#gmail.com) << this is wrong -- it's mixing my (recipient)
real name with the sender's email address!!
To: sammyhambone#hotmail.com
From: IamTheSender#gmail.com
Sent: Fri 10/18/13 5:49 PM
To: sammyhambone#hotmail.com (sammyhambone#hotmail.com)
Here is the rest of the code -- this code successfully sends out the email, but by using one of the above versions of the from variable, I either find the email go to the recipient's Junk folder or the 'From:' part in the email's title is screwed up as described above:
$theRecipient = "aLoyalUser#hotmail.com";
$to = $theRecipient . " (" . $theRecipient . ")";
$subject = "the subject is Pear and emailing.";
$body = "Ach, megotts lads, comes the blarney stone."
$host = "smtp.1and1.com";
$port = "25";
$username = "myAuthName#oursite.com";
$password = "12345";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$headers['From'] = $from; // one of the two 'from' versions given above
$headers['To'] = $to;
$headers['Subject'] = $subject;
$mail = $smtp->send($theRecipient, $headers, $body);
// tried this, no help
$mail = $smtp->send($to, $headers, $body);
I need to get the Sender's email message to the Recipient's Inbox but the "From:" part of the email's title must not say "Sam Hambone (IamTheSender#gmail.com)".
What's missing here?
The best example of a website that probably everyone is familiar with is -- I have noticed that sites like Craigslist are always able to get emails routed to me when I place an ad to sell something (clothes, furniture, etc.)
There are other examples where a website 'relays' one of their user's email to my inbox successfully. That is what I was after, as that is what our site needs to do -- when a user needs to contact another user they send an email through our site (since that's how they came to be aware of the other user) and we need to relay their email to our other user.
No one (yet?) seems to have concrete experience on how to do this, so I'll close out this question in just a bit.
As you may or may not know, there is a war on spam *. This is because spammers are so prolific that they're using a significant amount of resources on servers like processing power (for filtering spam). They also threaten to ruin the usefulness of things like e-mail if we do not stop them. Therefore, because they're a major practical concern, there are all sorts of very sensitive spam filters across the internet that will put you in junk mail for reasons ranging like sending to too many messages that bounce, sending to a particularly unlucky inactive e-mail address (called a spam trap), etc. It is conceivable that the anti-spam software that is running is using this particular e-mail from format as one of it's heuristics to detect spam. It might be argued that using this as a heuristic is irrational or overly-sensitive, but as I've mentioned, the war on spam has resulted in some spam filtering mechanisms that are quite sensitive. If you want to do a test, perhaps try white listing the from e-mail address or turning off the spam filter(s) (in addition to server-side filters, e-mail clients and virus scanners may include some filtering abilities) and see if the spam filter is the culprit.
Update: Now that I am aware of the purpose of this e-mail software (to relay a message sent from the site from one user to another user, while presumably protecting their privacy) I can provide a better suggestion:
The notifications that I receive from websites to tell me that a user has messaged me simply contain the name of the website in the from line rather than a person's name. Example:
Website Name (no-reply#websitename.com)
(Note - it could be important to some spam filters that the website name in the from line matches the domain name exactly.)
If that doesn't seem to make it through the spam filter, I would try the following ideas:
Check out other "from" lines from other websites to see how they're doing it and try out any patterns you find.
Consider signing up with an e-mail reputation service to see whether they can help you.
Test to see whether this quirk is a big issue or a small one by determining which specific piece of spam software is flagging these, and then finding out how many users they have. You could also try sending these e-mails to a variety of other e-mail services to see whether they junk them. It may be that you have some old or unpopular spam filter here that's behaving in a way which actually is not indicative of what will happen to most of your e-mails.
Citation: "Spam Wars" by MIT Technology Review
I'm a newbie in PHP. My goal is to send an email to the user registered in my system.
Here is my code:
$msg= " Hi $gen./$lName, copy and paste this code in order to activate
your account copy and paste this code:$num" ;
$email = "$emailadd";
$name= "GoodFaith Network Marketing Inc.";
$subject = "Account Activation";
$message = wordwrap($msg,70) ;
$sender = "cjoveric#myalphaedge.com";
$mail_header="From: ".$name."<". $sender. ">\r\n";
$sendmail=mail($email, $subject,$message, $mail_header );
I was able to send an email, but my problem is I want to know if the user's email address exists in Yahoo, GMail or other mail services.
Is there any way I could filter out invalid emails?
Use SMTP mail the best and easy to use SMTP.
$mail->IsHTML(true);
$mail->From="admin#example.com";
$mail->FromName="Example.com";
$mail->Sender=$from; // indicates ReturnPath header
$mail->AddReplyTo($from, $from_name); // indicates ReplyTo headers
$mail->AddCC('cc#phpgang.com.com', 'CC: to phpgang.com');
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send())
{
$error = 'Mail error: '.$mail->ErrorInfo;
return true;
}
else
{
$error = 'Message sent!';
return false;
}
Not really. About the best you can do is send an email and see if the user responds to it.
Doing a regex check on email address can be frustrating for some users, depending on regex. So, I recommend to skip your regex test and just send the verification email with a confirmation link -- anything else will leave your application brittle and subject to breakage as soon as someone comes up with a new DNS or SMTP extension. It's best to get that dealt with when their paying attention.
For example:
-a confirmation code that needs to be filled in your website
-a link, going to your website, that needs to be visited
And still it is uncertain whether the email is existing afterwards, as it is easy to simply create a temporary email to pass the validation and delete it afterwards.
Instead of validating email addresses you can use the Google API to let your users sign in using their account. It is also possible to use OpenID on a similar way. Though, even this is not 100% perfect. But heay, nothing is 100%. We all try to make is work as we want as much as possible. That's it.
PS: ICANN is expected to approve UNICODE domain names Real Soon Now. That will play merry hell with Regex patterns for email addresses.
I've just updated a contact form to use PHPMailer to stop emails being marked as junk, with no luck.
It's a fairly straight forward setup I'm using but its still going into peoples junk mail.
Here is my script, I was wondering if anyone could tell what was wrong?
include_once('../inc/phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$name = $_POST['name'];
$email = $_POST['email'];
$body = "Name: ".$name."\r\n";
$body .= "Email: ".$email."\r\n";
$body .= "Message: ".$_POST['message'];
$mail->From = "mailer#blah.com";
$mail->FromName = "Contact BLah";
$mail->Subject = "Contact From: Blah";
$mail->Body = $body;
$mail->AddAddress("john#blah.com", "john");
$mail->AddAddress("david#blah.com", "david");
if(!$mail->Send()) {
$errorMsg .= "Error sending message, please try again later.";
} else {
$errorMsg .= "Message Sent successfully.";
}
I thought that PHPmailer normally takes care of inserting proper headers?
Any thoughts?
EDIT: Added spam score
-Spam-Status: "score=0.0 tests=none version=3.1.7 cmae=v=1.0 c=1 a=8nJEP1OIZ-IA:10
a=soyWjZv28gkhNSke5wm04A==:17 a=fqdOs_Nl9wd82e3SDigA:9 a=l-lynuxnH-gfU2bevBoA:7
a=wPNLvfGTeEIA:10 a=nymK5Bb5l1cA:10 a=_6wjLm_vFSYA:10 xcat=Undefined/Undefined"
X-Spam-Level: *
EDIT 2: I just tried the script on a different server from the clients and it has the same result. Do I have to send through the SMTP setup for it not to be classed as spam?
Some reasons your mail can get marked spam:
You're sending spam
Your IP, or a block of IPs surrounding your IP has been marked as a spam source on one or more blackhole lists
The content of the email is triggering spam filters.
The recipient has added you to their blacklist
The recipient didn't add you to their whitelist
You're sending a mixed source mail ("From: xyz#example.com", but sending it from "someotherdomain.net")
SPF records for your server are misconfigured/not configured at all
Domain keys are misconfigured/not configured at all
etc...
PHPMailer is a tool. Consider it a hammer. The hammer may have bent the nail, but only because the wielder didn't aim right.
The only way you'll solve this problem is by examining the bounce messages (if any), and whatever showed up in the recipient's mailbox. If they receive the mail, but it goes into a spam folder, then get a copy of the mail and examine its headers. Most spam filters will put their spam score/reasoning in there.
Small hint:
add in a line like so
$mail->AddReplyTo( 'mailer#blah.com', 'Contact BLah' );
It should decrease your SPAM rating significantly.
I was having the same problem using PHPMailer, and here's what fixed the problem for me: set the Sender (this is different and distinct from the "From") to a valid email account for the domain you are sending the email from. This causes PHPMailer to properly set the "envelope-from" information so that the email passes SPF and Sender-ID validation. Without doing this, the "envelope-from" is a OS user id and server combination which will not be verifiable.
Example Code:
$mail = new PHPMailer;
$mail->From = 'from_email#domain.com';
$mail->Sender = 'sender_email#domain.com';
...
It is not necessarily PHPMailer's fault, there are several possible reasons for your server to be blacklisted. You can check here to see if this happened
I am using PHPMailer to send a confirmation email for newly registered users in my social network. But I found out most of them have ended up in user's spam list. (Hotmail and Yahoo). How to avoid this?
This is my script
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = mSMTPAuth();
$mail->SMTPSecure = mSMTPSecure();
$mail->Host = mHost();
$mail->Port = mPort();
$mail->Username = mUsername();
$mail->Password = mPassword();
$mail->From = mFrom();
$mail->FromName = "SiteName";
$mail->Subject = "SiteName New Account Activation";
$mail->IsHTML(true);
$mail->WordWrap = 50;
$mail->Body = "<h2>Welcome to " .$sitename. " " .$username. "! </h2><br><br>";
$mail->Body .= "Please click on the link below to verify your email address:<br><br>";
$mail->Body .= "<a href='".$base. "verify.php?a=" .$gen_key."'>".$base. "verify.php?a=" .$gen_key."</a>";
$mail->Body .= "<br><br>Regards<br>";
$mail->AltBody = "Welcome to " .$sitename. " " .$username. "!\n\nTo verify your email address, please click on the link below:\n\n".$base. "verify.php?a=" .$gen_key;
$mail->AddAddress($email);
$mail->Send();
$mail->ClearAddresses();
To maximize the odds of your email arriving, there are three things you need to check:
Make sure the computer sending the email has a Reverse PTR record
Configure DomainKeys Identified Mail (DKIM) in your DNS and code
Set up a SenderID record in your DNS
details at:
http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html
There's not much you can do about it. Most of those mail providers have lists of common IP addresses, hostnames, and other data that often get flagged as spam and if your emails match the criteria they automatically get filtered. All you can really do is tell your visitors to add your email address to their allow list before registering so the email will go through to their inbox.
Honestly, don't worry about it. If they see your emails are regularly being marked as 'not spam' then they'll eventually add an exception for it. Just tell users to check their spam folder if they don't see the email like every other site does. Usually if they mark it as 'not spam' in that folder it will automatically add an exception for that address so any other emails you send them will end up in their inbox.
Do you have a reverse DNS entry for the server sending the confirmation e-mails?
If not, this might be a rDNS issue. Some sites are much more likely to mark a message as SPAM if the IP and name of the sending host don't match according to rDNS.
Otherwise, you might try sending confirmation e-mails to your own accounts on major e-mail sites like yahoo, hotmail and g-mail and then tweaking the wording until it gets past the spam filters.
Hm, there is SOMETHING you can do:
* Scrap the HTML. This looks like spam, especially with low text
* Write some more text, please.
Short HTML mails may rise up quite on the spam list.
I discovered that any variation of the word "confirm" in the title ends up in my spam bucket. I found other words that also do this: "purchase", "hurry", "order", "bargain", and "imminent".
This may not be true in all emails, but it happens in mine. It may be because those words appear in most of the emails I mark as span. It also may be that a local sysop made a filter and distributed it to all of us.
You can try using sendGrid apis which will helps, they charge but I think it is worthy. They support most popular languages : Nodejs, PHP, Java, ....