This code what i am using to send mail but unfortunately mail goes to spam folder. I tried both gmail and hotmail but case is same . php code is:  &lt;?php if($_POST) { //check if its an ajax request, exit if not if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {     die(); }   $to_Email       = "zinan09@gmail.com"; //Replace with recipient email address $subject        = 'My email from Somebody out there...'; //Subject line for emails  //check $_POST vars are set, exit if any missing if(!isset($_POST["userName"]) || !isset($_POST["userEmail"]) || !isset($_POST["userMessage"])) {     die(); }  //Sanitize input data using PHP filter_var(). $user_Name        = filter_var($_POST["userName"], FILTER_SANITIZE_STRING); $user_Email       = filter_var($_POST["userEmail"], FILTER_SANITIZE_EMAIL); $user_Message     = filter_var($_POST["userMessage"], FILTER_SANITIZE_STRING);  //additional php validation if(strlen($user_Name)&lt;4) // If length is less than 4 it will throw an HTTP error. {     header('HTTP/1.1 500 Name is too short or empty!');     exit(); } if(!filter_var($user_Email, FILTER_VALIDATE_EMAIL)) //email validation {     header('HTTP/1.1 500 Please enter a valid email!');     exit(); } if(strlen($user_Message)&lt;5) //check emtpy message {     header('HTTP/1.1 500 Too short message! Please enter something.');     exit(); }  //proceed with PHP email. $headers = 'From: '.$user_Email.'';  @$sentMail = mail($to_Email, $subject, $user_Message .'  -'.$user_Name, $headers);  if(!$sentMail) {     header('HTTP/1.1 500 Could not send mail! Sorry..');     exit(); }else{     echo 'Hi '.$user_Name .', Thank you for your email! ';     echo 'Your email has already arrived in my Inbox, all I need to do is Check it.'; } } ?&gt;   Is there any missing function which i need to add or modify to solve this problem
949
This is a tricky one and I've always relied on techniques, such as permission-based emails (i.e. only sending to people you have permission to send to) and not using blatantly spamish terminology.  Of late, some of the emails I send out programmatically have started being shuffled into people's spam folder automatically and I'm wondering what I can do about it.  This is despite the fact that these particular emails are not ones that humans would mark as spam, specifically, they are emails that contain license keys that people have paid good money for, so I don't think they're going to consider them spam  I figure this is a big topic in which I am essentially an ignorant simpleton.
10282
I am having an html email template which uses certain merge fields from a custom object. Now I am using following apex code to send certain emails to users.  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();          mail.setTargetObjectId(t.OwnerId);          mail.setTemplateId(et.Id);         mail.setWhatId(t.Id);          mail.SaveAsActivity = false;         Messaging.sendEmail(new Messaging.singleemailMessage[] {mail});   Code is saved without error but when I run it it says "can't use whatId when sending email to users". Can anyone explain me how to overcome this error? When I use a visualforce template then same code works fine.
8611
I am using PHP with Apache on Linux, with Sendmail. I use the PHP  function. The email is sent, but the envelope has the Apache_user@localhostname in MAIL FROM (example nobody@conniptin.internal) and some remote mail servers reject this because the domain doesn't exist (obviously). Using mail, can I force it to change the envelope MAIL FROM?  EDIT: If I add a header in the fourth field of the mail() function, that changes the From field in the headers of the body of the message, and DOES NOT change the envelope MAIL FROM.  I can force it by spawning sendmail with sendmail -t -odb -oi -frealname@realhost and piping the email contents to it. Is this a better approach?  Is there a better, simpler, more PHP appropriate way of doing this?  EDIT: The bottom line is I should have RTM. Thanks for the answers folks, the fifth parameter works and all is well.
34937
I have my own email server and I've recently noticed that many of the emails I sent ended up in the recipients' spam folder. I have verified the IP of my mail server and it's not in any blacklist. What could be causing this? Could it be that my IP doesn't have a long history? How can I fix this?
118184
Whenever I send a mail from myaccount@example.com to a Gmail account, Gmail treats it as spam.  I'm talking about the one e-mail I send to a prospect after I've met him (it is surely non-spam mail). It's happened several times already:  "Hey!, you never sent that e-mail you promised me" the prospect says.  "How come...? I did send it. Check the spam e-mail" I answer.  "Oh,  there it is..."  I think it has to do with example.com not being a well-known domain.  How/Where should I complaint about this?
111739
I'm getting a lot of mail in my root user's mail account. This appears to be mostly reports and errors from things like cron scripts. I'm trying to work though and solve these things, possibly even have them be piped to some sort of "dashboard" - but until then how can I have these messages go to my personal e-mail account instead?
1429
This is a  about how to handle email sent from your server being misclassified as spam.  For additional information you may find these similar questions helpful:                    Sometimes I want to send newsletters to my customers. The problem is, that some of the emails get caught as spam messages. Mostly by Outlook at the client (even in my own Outlook 2007).  Now I want to know what should be done to create "good" emails. I know about reverse lookup etc., but (for example), what about a unsubscribe link with an unique ID?  Does that increase a spam rating?
60515
What is the advantage of using wp_mail() over mail(). Codex says they're similar, but they seem to be very similar.
123595
I have a following setup:   linux box with postfix configured to be responsible for example.com domain domain's MX servers are configured so that mail sent to example.com is sent to google mail servers several user accounts on linux machine exist (same machine also hosts example.com site)   When someone from the outside attempts to send mail to address ending with @example.com, it gets routed to google mail (and there handled appropriately).  When linux machine tries to send mail to outside world, mail is delivered correctly, as reverse dns and spf records are configured correctly, so linux machine is valid mail sender for example.com domain (along with google mail servers).  However, here's the problem. When php application (hosted at linux box) tries to send mail to someuser@example.com (and someuser doesn't exist on linux box), it fails, since it doesn't even consult google mail servers, but postfix smtp locally concludes that "someuser" is unknown.  So, the question is: how do I tell postfix to relay mails sent to @example.com domain to google mail servers (so, to servers specified in MX records), IF and only if a mailbox is not found locally.
40272
I am facing an issue with Ubuntu server. I am running a PHP script using a cron job which executes every 5 minutes. This folder spool/mqueue is showing 112GB space. The scripts job is to fetch data from MySQL. If there is no data it will show an error. Now there is an error and cron is trying the send the mail to the users where user email is not defined and it is creating log file in mqueue folder.   How to customize cron so that it would not send mails and write logs?
120237
Prima facie this is impossible but perhaps someone has some kind of hack to do it. This is one of the last things holding me back from switching to Gmail from Pine.  To be clear, bouncing a message is like forwarding but leaving all the headers intact. It sort of amounts to spoofing the email, which perhaps is why Gmail doesn't support it. To the recipient of a bounced email, it seems as if they were just BCC'd.
39468
I have a form on my front-page. It sends the entered address to Google API and returns the JSON to wp_options. That works fine. I am using update_option to do that, so it rewrites the meta_key each time. How would I go about having each address entered remain?    $address = esc_html( $_POST['address'] );    //assign JSON object to var using  geocodeing function('address') input    $address_results = gmap_geocode($address);    // transfer data to options array   $options['py_name'] = $py_username;   $options['address'] = $address;   $options['coords']  = $address_results;    // create and name the option_name and set fields with $options array   update_option( 'row_name', $options );
23769
There is a newsletter I receive that Gmail insists should go into the spam folder.    How can I mark it as not spam and move it to the inbox?  I know how to do it in Gmail, but not in Inbox.  How can I tell Gmail not to send that newsletter to spam in the future?
108709
I want a utility that does something like this:  email --subject="xxx" --body=body.txt --to=to_address@hostname.com   (using pre-configured sender information for e.g. gmail). Note that body.txt is plain text and should be the body of the message, not an attachment. If the body is omitted it should pop up an editor and let me type in my message that way.  I could hack together a quick script that does this, but I was wondering if there's an easy way to do this with common unix tools?
291
Is there a regular expression to validate an email address in JavaScript?
106060
I'm using the command:  echo "Test if email can be sent from server" | mail -s "Test" myaccount@gmail.com  This is on an Ubuntu Server 12.04 completely up to date.  To catch you up on my troubleshooting:  1) I have installed mailutils with the "Internet Site" option (or whatever that internet option was; I can't remember exactly what it was called off the top of my head).  2) I have added myself to the group 'mail'.  3) I have checked that my ISP does, in fact, block port 25. I followed  using port 587, which is unblocked (I'm not sure that this has an effect on outgoing mail; it looks like a mail server to me)  4) I've also tried echo "Test if email can be sent from server" | sendmail -f myaccount@gmail.com myaccount@gmail.com, but this also appears to do nothing.  5) I am worried that gmail is receiving on port 587, but that it doesn't know what to do with the traffic. Is this an unfounded consideration?  6) My gmail user name contains a '.' before the '@gmail.com'. Is it possible that this is confusing the mail and sendmail commands? (edit: after some more experimenting, this is probably not the problem)
44509
This is a little confusing to explain, so bear with me here...  I want to set up a system where a user can send templated emails via my website, except it's not actually sent using my server - it instead just opens up their own local mail client with an email ready to go. The application would fill out the body of the email with predefined variables, to save the user having to type it themselves. They can then edit the message as desired, should it not exactly suit their purposes.  There's a number of reasons I want it to go via the user's local mail client, so getting the server to send the email is not an option: it has to be 100% client-side.  I already have a mostly-working solution running, and I'll post the details of that as an answer, I'm wondering if there's any better way?