简体   繁体   中英

Is SMTP server required to send mail through web server, by using JavaMail API?

Is a SMTP server required to be able to send mail through a web server, by using JavaMail API? When I am using localhost for sending mail, it works, but when I upload it on server it doesnt work and gives error:

No such smtp provider

How can I solve this?

A SMTP server is always required to be able to send emails, like as a HTTP server is always required to be able to send webpages. This is regardless of the website and the mail API you're using. A HTTP server is not the same as and does usually not include a SMTP server.

You could make use of the SMTP server associated with your own existing email account, such as the one from your ISP or public mailboxes like Gmail, Yahoo, etc. You can find SMTP connection details at their documentation. You usually just need to know the hostname and the port number. The login details are just the same as from your email account.

With the ISP/public mailboxes you're however restricted to using only your own address in the From field of the email and usually also in the amount of emails you're allowed to send at certain intervals. If you'd like to get around this, then you need to install your own SMTP server, for example Apache James , which is Java based, or Microsoft Exchange and so on.

Once you have a SMTP server, then you'll be able to send emails using the JavaMail API or eventually the more convenienced Apache Commons Email .


I forgot to add, if you're using 3rd party web hosting, then it's good to know that most of those 3rd party web hosting providers also offers a SMTP server as well. You'd like to consult the hosting features and figure the connection details in their documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM