Zero-dev
Zero-dev

Reputation: 340

Sendmail Cannot open and load mail server properties file

i tried to make a EmailSender in my application java

i make i frame for email, and i search with google for some exemple that can help me,

so i find this tuto that is very useful http://www.javapractices.com/topic/TopicAction.do?Id=144

but i do not understand what mean this configuration

# Configuration file for javax.mail 
# If a value for an item is not provided, then 
# system defaults will be used. These items can 
# also be set in code.

# Host whose mail services will be used 
# (Default value : localhost) 
mail.host=mail.blah.com

# Return address to appear on emails 
# (Default value : username@host) 
[email protected]

# Other possible items include: 
# mail.user= 
# mail.store.protocol= 
# mail.transport.protocol= 
# mail.smtp.host= 
# mail.smtp.user= 
# mail.debug=

After run i have this error,

Cannot open and load mail server properties file.
Cannot send email. javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
    java.net.ConnectException: Connection refused: connect

help, and thanks

Upvotes: 1

Views: 1084

Answers (1)

spiritwalker
spiritwalker

Reputation: 2257

  1. about the exception : You need to make sure there is SMTP server set up on localhost:25;

It makes sense if the app is running on production environment(or integrating testing environment), which has a SMTP set up on it's own. It does not make sense if you the app is running on your local machine, because most likely there is not SMTP server.

So if you are testing the Email function locally, you need to make sure SMTP is configured with correct host and port. Do a google search, you can find some public SMTP server provider with details.

  1. about those configuration details: You can find all the javamail properties details at http://javamail.kenai.com/nonav/javadocs/com/sun/mail/smtp/package-summary.html

Upvotes: 2

Related Questions