I have an application hosted on amazon EC2. Now a user can send out invitations to join but on most email clients its showing up in the spam folder. Is there anyway to find out on what criteria it is actually being filtered.
First of all, please check to see if your domain/IP has landed on any blacklists:
https://www.mxtoolbox.com/blacklists.aspx
Second of all, have you set an SPF record? Explanation below:
http://www.openspf.org/Introduction
https://mxtoolbox.com/spf.aspx
This is a way to qualify a particular server/IP as being a valid for relaying/sending mail on behalf of a particular domain. Sendmail - or whatever PHP is configured to use to send mail - can actually send mail for any user on any domain (i.e. "spoofing"). However the server receiving the mail (e.g. a recipients POP3 server where received mail is stored and filtered) is probably going to check whether or not that server is supposed to be sending mail for that domain based on what's in the domain's DNS entries. In particular, it will probably check the SPF record, so you will need to set this. You should consult whichever service manages your DNS (i.e. your nameservers) for how to do this. You can look up where your nameservers are using the whois, dig or nslookup commands (or just use a web based whois service) - look for the "nameserver" entries, often denoted by "ns".
This is one of a number of factors that may be affecting whether or not your mail goes to spam. This subject is something of a "can of worms" and goes way beyond setting up your PHP mail function correctly. Rather than trying to reiterate all of these issues here, I'll direct you to this post on serverfault:
https://serverfault.com/questions/106598/all-my-emails-to-yahoo-hotmail-and-aol-are-going-to-spam-though-ive-implemen
Do you use 5th parameter in mail function?
mail('reciever#address.com', 'the subject', 'the message', null,
'-fyour#address.com');
It helps sometime.
Also maybe your IP was blocked before you start to use it.
Related
First of, let me just say that I know similar questions have been asked
Here
and here
But, there are problems with both questions. Question one has only one answer (which isn't helpful) and question two needs to work with Google Enterprise.
I have a LAMP stack hosted on Linode which hosts multiple sites each with a separate file in the sites-available folder. I have a specific domain which we will call myawesomedomain.com. Now, myawesomedomain.com has nothing in it right now and will not have any proper, full-fledged site. Only a simple form. The fields will consist of:
Username
Email Address
Password
Here's what I want. Whenever a user signs up, an email is automatically created with the username username#myawesomedomain.com. From that point on, whenever email is sent to username#myawesomedomain.com, the email is automatically forwarded to the email the user signed up with so that the email is never stored on my server (and therefore does not take up space).
So, my essential questions are:
How do I automatically create email addresses from PHP
How can I have the emails automatically forwarded to another email address in a MySQL database and not stored on my server.
What mail server should I be using and how should I set it up so it doesn't interfere with the rest of my sites.
Is there anyway that a lack of spam and virus filtering could effect me. As in, if a hacker sends a PHP file to username#myawesomedomain.com, is there any way that my server could be affected.
Whatever else you feel is needed.
I've heard of Postfix but I don't know much about mail servers...
Sorry for the long(?) question and thank you in advance.
edit
Should I put this on ServerFault instead?
The "creating an email alias from php"-part is not a problem. If you're running postfix as a mail server it's as simple as inserting a row into a mysql table.
INSERT INTO myaliastable (pattern, alias) VALUES ("john#myawesomedomain.com","john#example.net")
see:
http://www.postfix.org/MYSQL_README.html
http://www.postfix.org/postconf.5.html#virtual_alias_maps
BUT:
creating a forwarder service like this comes with a lot of problems you should be aware of:
you MUST verify the target email adress before you enable that forwarder(send message, have the recipient click on a link) or spammers will signup accounts and use your system as open relay
you MUST run a very good spamfilter... forwarding spam is no different from sending spam and will get your server blacklisted
if a target server starts rejecting your forwarder for any reason you will be sending backscatter which again can get your server blacklisted
if the sender domain uses SPF records and the target of the forwarder checks SPF, forwarded mail will be rejected. you could add SRS rewrites, which unfortunately is not that simple in postfix
since you state you don't know much about mailservers I would strongly advise to read up on them first, check out best practices on spam prevention and then tackle this project again.
i am writing a newsletter module in php/mysql.
how can i send email to site subscriptors that doesn't cause my mail server get blocked ? i mean it doesn't treat as a spam sender?
The full answer to this question is really outside of the scope of this site, as much of it will involve administrative tasks with the domain and server(s) involved.
But the short answer is: Don't do this! You will just end up getting your server's IP blacklisted, making even low-volume e-mail sending worthless from that server.
You should look at other options; an RSS feed, a third-party, well-run mailing service (like Constant Contact), or something else.
Use Cron job to do this and send mails in small chunks with a time difference.
There are several rules that you need to follow if you want to send out emails from your site and have then not being flagged as spam:
Start with the most obvious: check to make sure IP address of your server is not on any spam black lists. Try this site: link text
By default all emails sent from a website hosted on Apache server are send from the user Apache server runs under, usually 'nobody'. This is a red flag for spam filters, so you have to modify the value of 'return-path' header which is not always allowed by email server. If you can't modify return-path, then you need to start apache as another user, create a new account for your apache server, name it anything you like as long as it's not 'nobody' and then configure apache server to run as this new user
Very important to have reverse DNS entry for the IP address you use for sending out emails. That reverse DNS entry must point to same domain name that points to this IP address. This is actually the most important thing to do. Since only a webhost can add reverse DNS entry, you should ask your host to do this for you.
Other smaller steps that can help is to configure an appropriate spf entry in your DNS server and another one is to use digital signature to sign all your outgoing messages. I used to use a program called dksign for this, it's probably not the most up-to date program now, so do your research and find the best way to sign your messages.
Use common sense when creating subject lines. If you say "free discount offer" in the subject line or something similar or "get viagra", your message will probably be flagged as spam no matter what.
I'm getting single emails, for each undelivered address that mail() send couldn't reach.
Since this can be a painfull process, to keep copy pasting every single address, I'm wondering if it's possible to access a LOG or something ?
Some notes:
- I've got this app running on a GoDaddy server (I know it sucks);
Thanks for your atention ;D
There is no log as such, because feedback from the receiving mail server is not immediate. There's only the "undeliverable" messages that get returned to you.
However, it should be possible to specify a reply-to or errors-to address pointing to a separate mailbox. That would make it easier to find out which recipient addresses failed.
That is the best way I can think of to group failed messages.
I'm wondering if it's possible to access a LOG or something ?
Maybe - it depends on what the MTA (mail transport agent) is, how it's configured and whether you have the permissions to access the file.
I've got this app running on a GoDaddy server
Then the above are all questions for your GoDaddy provider.
The MTA log should record details of messages which the MTA failed to offload elsewhere but the elsewhere may be a smart relay (i.e. still on the sending side) - in which case you'd need to look at the relay MTA's logs to see if it managed to pass the message on to one of the recipient MXs. Even if the message got as far as a recipient MX, you don't know that it was successfully delivered. By convention, the receiving system should send back a DSN if it fails (and you can specifically ask for a DSN regardless of outcome) but a lot of systems don't implement this properly.
Regardless it may provide information about some messages which fail - you'd need to poll the return mailbox to identify failures.
C.
If mail() fails immediately, it returns false and you went get any e-mail. However, if a problem arises after the mail has been sent but before it has been received, you get an e-mail.
The mail() function will send the e-mail to some mailserver, which will send it to another, until it reaches its destination. When the user does not exist, this is only discovered at the destination mail server and it responds with an e-mail, called a bounce.
There is no way to group these bounce e-mails, as the destination mail servers do not know that they came from the same script.
Another option you have is to pipe the incoming emails to a PHP script and process it that way. How this is accomplished depends on the server setup you have and whether your server is set up to use sendmail or exim.
A good tutorial on this is located here.
I have some problems with the email system for CodeIgniter:
First, the emails I send out (registration, confirmations) are getting caught in standard spam filters in gmail and other mail clients. How do I get around this? How do companies like Facebook get their emails through consistently?
Second, the mailer is working locally but once we deploy it it no longer runs (doesn't send emails) but all the other forms run just fine. Anyone ever run into a problem like this?
Thanks for all the help!
I can't really answer your first question - it's not specific to CodeIgniter. You just need to make sure your email doesn't look like spam. In short - there's no way of guaranteeing your e-mail will not end up in a spam filter.
As for the second question, I expect your production server needs to be configured properly for email. You probably need to configure CodeIgniter to send email properly. I would suggest setting up an SMTP server (or using an existing one) rather than using the standard PHP mail which I think CodeIgniter uses by default.
Regarding spam, most organisations are very secretive about how they prevent spam (not wanting to publish information which helps the spammers) and in some cases they don't actually know - an obvious examlpe of this is bayesian filtering - but, for example, hotmail use a completely unaccountable army of volunteers to manually classify emails.
Do and get a copy of spamassassin and try to reverse engineer how the standard rules work. Obvious things to check are:
1) AVOIDING LOTS OF CAPITALS
2) don't mention the 'V' word
3) make sure you've got a current and restrictive SPF 1.0 policy published
4) make sure your sending from an address which has A and PTR DNS records
5) Do provide a reply-to and from email address which use your domain in the address
the mailer is working locally but once we deploy it it no longer runs
doesn't send emails
Which? These are 2 totally seperate things. If the code is falling over (if so why have you not provided the error details) then its likely a PHP version issue or a problem with the connection to the MTA (or the PHP mail config).
The latter is a problem with the MTA itself.
99.9% of problems reported as PHP mail failures have nothing to do with PHP and are problems with the MTA.
Enabled detailled error reporting for your MTA and see where it is failing.
C.
You may have to configure the email on your server differently than your local development environment. I've had to in the past.
There are two basic ways that PHP can send mail:
Via a UNIX program called "sendmail" (only on non-Windows servers and only if it is installed - check with your hosting provider)
Via a SMTP server.
If you've configured CodeIgniter to use SENDMAIL, check to ensure that the Sendmail path is correct. Your hosting provider usually provides this somewhere in their online documentation.
If you're using SMTP, you need to make sure that your server can contact the SMTP server. You can do this by logging into the server via SSH and typing "telnet your.smtpserver.com 25". If you get an error message about not being able to connect, you know you have a problem with your hosting provider connecting to your mail server.
I've been able to diagnose this problem by enabling logging on my production server (http://bit.ly/4pprd6) and adding log_message('error', $this->email->print_debugger()) right after I attempt to send a message.
I have set up an AJAX contact form on a client's website.
The problem is that the email is not getting through to the client's inbox.
I set up the client with Google Apps (in the same way I did for myself).
I used the same contact form with my email address and it works. But with any email addresses on their domain it doesn't!
All members of the domain are receiving 'ordinary' emails.
What could be the difference that's stopping mail() emails getting through?
UPDATE
Ok so I managed to solve it. Turns out that using a CNAME to point the domain to the correct server wasn't enough for sendmail so I had to change it to an A record pointing directly to the server. Strange but true. Thanks for the help folks, you pointed me in the right direction :)
It depends on the both settings on your server and the server on the receiving end.
hotmail for example requires the use of correctly configured SPF records.
many mail-receiving servers (including hotmail) require the email to originate from a Fully Qualified Domain Name. It is very possible that your e-mails send from PHP do not comply with this rule. (there is a good chance they originate from 'apache')
see hotmail self help and hotmail postmaster info
PHP's mail() function does not include a lot of headers with your mail, so you will need to supply them yourself.
The more hops your mail makes on it's way to it destination, the more likely it is to be tagged as spam.
So it might be a better option not to use PHP's mail function and instead use a mail library that connects to an SMTP server just like your desktop mail application does.
All in all, I would place my bets on an external library: Pear::Mail (documentation)
You could also read: how do you make sure email you send programmatically is not automatically marked as spam
UPDATE
Failing the SenderId or SPF check can get your message dropped before it even hits the users inbox. The message will not end up in the users junk folder, it will go directly to /dev/null.
I know this is at least true for hotmail and live mail. I see no reason for other hosts not to have implemented the same policy.
I recommend using PHPMailer (including their SMTP) library instead. It is reliable compared to mail and allows you to create fully customized emails.
http://phpmailer.worxware.com/