Google wrote:In order to prevent spam, Gmail refuses mail when the sending IP address does not match the sending domain. To send mail from your server to Gmail, we suggest using the SMTP relay provided by your ISP. Please note that we are unable to whitelist IP addresses or otherwise make exceptions at this time.
your problems with the Gmail server come down to the spam prevention mechanisms almost all SMTP servers on the internet are using today not just Gmail.
In order to prevent spammers from using a SMTP server as a relay for their spam mails almost every mail provider requires you to use SMTP authentication when sending mails. That means your mail program usually is configured to log in into a SMTP server with a username/password before it will be allowed to use this SMTP server.
It's not enough to have correct settings in the "from" or "to" field of an email because ALL data in an email can be spoofed and manipulated on its way through the internet. Neither the Gmail server nor any other professional SMTP server will trust you just because you have a valid "from" address in your mails!
If you're using an own, local SMTP server which sits between your host sending the emails and the Gmail server it's more likely that Gmail will accept the mails. BUT this local SMTP server should have a fixed IP address and a correctly set up DNS record (A record and reverse entry) so that Gmail is able to lookup and verify that this is a more or less trustworthy SMTP server. In this case it's still possible that you are using an IP range which is blacklisted.
For all this you have two practical solutions:
1.) If you have a fixed IP and access to configure DNS settings for it you could set up a SMTP relay which can be used by your application. Another advantage is that such a local mail relay can be used by all client applications in your network.
Then you would not send mails directly to the Gmail server but to your local mail relay. And the relaying SMTP server would forward your emails to the Gmail server. This would be an easy way for you because you wouldn't have to change anything in your code but the SMTP server (which should then point to your local relay). This is possible because it's relatively easy to set up a local SMTP server and simply allow any client from your local network to send mails without using authentication.
2.) You could send mails directly to the Gmail server but then you would have to use SMTP authentication/authorization in order to be allowed to send mails. You would have to use a valid Gmail account with username/password for your application to log in. Unfortunately - from what I read - Aspirin doesn't support authentication. It seems that it should just be used for simple applications in scenario 1.) and not for complex mail handling. In this case I think you will have to go for a more capable mail library like the JavaMail API.
I hope this explanations make the problem a little bit clearer for you ;-)
posted 11 years ago
Many Thanks Marco, for your detailed instructions.
Please read this is what I really need to implement.
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Devious Experiments for a Truly Passive Greenhouse!