<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% Request.setChacterencoding ("GB2312");%> <% @ page import = "java.util. *, Javax.mail. *"%> <% @ Page import = "javax.mail.internet. *"%> <% @ Page import = "java .util.date "%> <% @ page import =" java.sql. * "%> <% string countryid =" ", areaid =" ", userid =" ", sql =" ", etel =", Companyname = ""; ResultSet RS = NULL;
Etel = (string) session.getValue ("eTel"); CompanyName = Request.getParameter ("username"); try {string [] eTelid = etel.split ("-"); countryid = etelid [0]; areaID = Etelid [1]; userid = eTelid [2];} catch (exception e) {}%>
// Get the mail information in the HTML form String TTO = Request.getParameter ("to"); string Ttitle = Request.getParameter ("Title"); string tcontent = request.getParameter ("content"); tcontent = " String myemail = Request.getParameter ("myemail"); out.print (myemail); // ****************************************** ******************* OUT.PRINT (TTITLE TCONTENT); Properties PROPS = New Properties (); // You can also use Properties PROPS = System.getProperties (); / / props.put ("mail.smtp.host", "SMTP.163.NET"); // Store information of sending mail servers PrOP.PUT ("Mail.smtp.Host", "221.136.100.35"); PrOPS .put ("mail.smtp.auth", "true"); // simultaneously by verifying session s = session.getInstance (props); // Newly built a message session S.SetDebug (true) according to the property; MimeMessage Message = New MimeMessage (s); // Create a message object by the mail session
// set the mail InternetAddress from = new InternetAddress ( "yzhxy2002@etoall.cn"); message.setFrom (from); // set the sender InternetAddress to = new InternetAddress (tto); message.setRecipient (Message.RecipientType.TO , to); // Set the recipient, set its reception type to to message.setSubject (TTITLE); // Set the topic message.setText (tcontent); // Set the letter content (new date ()) ; // Set the send time
// Send mail message.savechange (); // Store mail information Transport Transport = s.getTransport ("SMTP"); //Transport.connect ("smtp.163.net", "boy", "iloveyou "); // Log in to the mailbox in the SMTP Transport.connect ("221.136.100.35", "163@toall.cn", "cn.etoall"); transport.sendMessage (Message, Message.GetAllRecipients ()); // Send a message, The second parameter is all // set of recipient addresses transport.close (); // update data / * sql = "select * from email where email = '" to "'"; rs = conn .executeQuery (SQL); f (rs.next ()) {out.print ("