• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Java Mail query

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'd like to be able to send emails to people from within a java application (for a project).
So far, I installed 1st Mail Server, then using the code (2 jars were added to classpath):


I was able to email myself, but other emails like hotmail addresses blocked the mail cause of something to do with spam.

So then I was looking at this...
authstmp

Which has a year service for £14.

The point is, I dont know how I put it together... Can I just use java with this authsmtp, or do I still need a mail server like 1st Mail Server as well,
which I only have 30 days on trial, so this is not good in the long run.

Can anyone explain the process for me before I make the purchase.
Thanks for any help/advice.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, using your own mail server will not work if the receiving host uses something like SPF (which looks up MX records of the sending mail server).

I'm not familiar with the service you mentioned, but they should provide you with a username, password and server name (or IP address) of the outgoing server, all of which you'd plug into your code. That should be all that's required.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, so to recap:

This authSmtp server is not a program I install on my pc, (like the 1st Mail Server), but is that company's actual server.
Then from java program, this sends message to their server which sends it to the intended email address.

Then I have this code...

So here I guess, under host section, I put in address of authSmtp's server,
and the last 2 will be username and password which they should provide.

I thought I would ask here first, since its java specific kind of, before I ask them anything.
Thanks, does this seem correct?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's correct. I would expect that they have instructions on their site as well, maybe accessible after you sign up. It may be slightly more complicated if they use a SMTP over SSL, but not much.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I got it paid for and setup, using:



I'm not sure if the port number line is correct, I just added that.
It says:
SMTP Server : mail.authsmtp.com
SMTP Ports : 23, 26, 2525 or 25 [not usually recommended]
I figured if the default is 80, then I should specify the actual port(maybe not?).

So, I used the username and password they supplied me, and tried to send myself an email:
And I got..


Exception in thread "main" javax.mail.MessagingException: 513 5.0.0 Your email system must authenticate before sending mail.



But also, all new accounts need to be verified which can take a few hours, so perhaps thats the problem.
I'll try it later tonight and see if theres any improvement.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may need to authenticate in a slightly different way, by using an Authenticator. See the JavaMail FAQ for how to do that: http://java.sun.com/developer/onlineTraining/JavaMail/contents.html

By the way, the default port is 80 only for HTTP; for SMTP it's 25.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, good stuff...

I see how it fits in with my existing code, I have null for the authentication thing,
so I need to do the MyAuthentication subclass next, gotta go to work, so I'll look at it when I get back.

Thanks for your kind help.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again, well I tried it but I get the same error:



I seem to have done what it asked for in the link, but it doesn't even call the getPasswordAuthentication() method, so I donno what to do now, any thoughts?
 
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm surprised this wasn't in the examples you looked at:
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, that helps, but now I get this error...


Exception in thread "main" javax.mail.MessagingException: 500 5.0.0 Envelope From Address of <[email protected]> is not authorised - go to: http://control.authsmtp.com


But I'm trying to send from my pc, not from an email address, so I donno what to do now. ???
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ooooooohhhhhh, I got it to work!!!


It was the 'email from address' that confused me, but I guess this is just the email address that the receiver sees when they get the message, and it gives them something to reply back to. I found some complete code...

webpage

I have to have this address added in the stmpServer. I'll keep you posted if I get stuck.

 
Paul Clapham
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

colin shuker wrote:I have to have this address added in the stmpServer.



Right, so the SMTP server you are using wants to make sure you aren't trying to send e-mail which appears to be from somebody else. Stealing e-mail addresses to use as "From" is a common spamming technique, so it's good that you aren't allowed to do that.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm, but I'm allowed 10 or 15 email addresses, so couldn't I just use other peoples email addresses anyway?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic