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: 35254
posted Mar 22, 2006 04:16:00
0
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.
Android apps – ImageJ plugins – Java web charts
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); } } }
subject: smtp mail server