Pregunta: | 2956 - QUIERO CREAR EN MI PAGINA E-MAIL GRATIS |
Autor: | yadira martinez vazquez |
Necesito crear en mi pagina E-mail, gratis, tengo mi pagina hecha con frontpage, y mi servidor de E-mail, con Windows NT.Ya tengo los formularios, pero como creo su buzon para enviar y recibir correos. |
Respuesta: | J. Montes |
Prueba con el siguiente código, insertado en una página jsp <html> <body bgcolor="white"> <font size=5 color="black"> <%@ page import="javax.servlet.http.HttpUtils" %> <%@ page import="java.util.*" %> <%@ page import = "java.sql.*" %> <%@ page import = "java.io.*" %> <%@ page import= "sun.net.smtp.SmtpClient" %> <% String from,to,subject,msgbody,serverName; try { from = request.getParameterValues("from")[0]; to = request.getParameterValues("to")[0]; subject = request.getParameterValues("subject")[0]; msgbody = request.getParameterValues("msgbody")[0]; serverName = request.getParameterValues("server")[0]; } catch (Exception e) // Generally Speaking, an Error getting one of these // Values means that it wasnt passed in; inform the user { out.println("You must call this JSP from this "); out.println("<A href=\"FormMail.htm\"> form</A>.<BR>"); out.flush();return; } %> Hold On A Moment while I try to Send Your Mail... <BR> <% out.flush(); // Here are the real guts of the mail sending try { sun.net.smtp.SmtpClient sm = new sun.net.smtp.SmtpClient(serverName); sm.from(from); sm.to(to); PrintStream msg = sm.startMessage(); msg.println("To: "); // Note dont use + for Performance |