This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes smtp mail server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "smtp mail server" Watch "smtp mail server" New topic
Author

smtp mail server

MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
Is there any free smtp mail servers around which does not require any authentication?

Thanks


God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
Every mail server can be configured not to require authentication.

Or are you looking for a server that's running w/o authentication and which you can connect to? Those do not exist anymore - it's a basic spam prevention technique to require authentication for publicly accessible mail servers.


Ping & DNS - my free Android networking tools app
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
If you want you can have your own email server (Apache James). You this server to send emails.
But beware mails which you send will mostly be going as spam, or will be stored in Bulk folder or even bounce back since receiving server might block non-domain incoming mails.


Manesh
MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
package test;
import java.io.IOException;
import java.sql.Date;
import java.util.Properties;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class NewMailServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
String error = null;
String subject=request.getParameter("subject");
String text =request.getParameter("comments");
try
{
Properties props = new Properties();
String from = "adress@gmail.com";
String ihost = "smtp.gmail.com";
String port = "465";
String auth = "tls";
boolean doAuth = !"none".equals(auth);
boolean useTLS = "tls".equals(auth);
Session session;
props.put("mail.from",from);
props.put("mail.smtp.host", ihost);
props.put("mail.smtp.port",port);
props.put("mail.transport.protocol", "smtp");

//props.put("mail.debug", "true");
if (useTLS)
{
props.put("mail.smtp.socketFactory.port",port);
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.ssl","true");



}
if (doAuth)
{
String username ="username@gmail.com";
String password = "*****";
Authenticator authenticator = new MyAuthenticator(username, password);
props.put("mail.user",username);
props.put("mail.smtp.auth", "true");
session = Session.getInstance(props, authenticator);
}
else
session = Session.getInstance(props);
MimeMessage message = new MimeMessage(session);
String addressee = "adress@gmail.com";
// for (String addressee : recipients)
message.addRecipient(Message.RecipientType.TO, new InternetAddress(addressee));
message.setFrom(new InternetAddress(from));
message.setText(text);
message.setSubject(subject);
Transport.send(message);
}
catch (SendFailedException e)
{
e.printStackTrace();
}
catch (NoSuchProviderException e)
{
e.printStackTrace();
}
catch (AddressException e)
{
e.printStackTrace();
}
catch (MessagingException e)
{
e.printStackTrace();
}
System.out.println("OK");
}
private class MyAuthenticator extends Authenticator
{
private String username;
private String password;
public MyAuthenticator(String username, String password)
{
this.username = username;
this.password = password;
}
public PasswordAuthentication getPasswordAuthentication()
{ return new PasswordAuthentication(username, password);
}

}
}
 
Don't get me started about those stupid light bulbs.
 
subject: smtp mail server
 
Similar Threads
java mail response code
Ant mail task - MS Exchange Server
My Application is not sending mail to external servers
Javamail for SMTP receiving
JavaMail without SMTP server...