• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

smtp mail server

 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any free smtp mail servers around which does not require any authentication?

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manesh Kumar
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}

}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic