• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Aspirin Cannot Send Mails

 
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using the code below




In this case, I'm getting the exception below:



Whats going wrong here?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well what the error message says! Your machine is not authorised to connect to the Google SMTP servers in this way, read the link they provide in the error message on how to resolve this.
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.



Hmmm! Seems like a very easy way to resolve this.
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Treimin,

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 ;-)


Marco
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many Thanks Marco, for your detailed instructions.

Please read this is what I really need to implement.
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic