-
Notifications
You must be signed in to change notification settings - Fork 1
/
mm.jsp
68 lines (48 loc) · 2.01 KB
/
mm.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<%@ page import="java.sql.*,databaseconnection.*"%>
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%
String id ="[email protected]";
// request.getParameter("id");
//String temp[]=null;
//temp=id.split(",",2);
//String link=request.getParameter("link");
String host="", user="", pass="";
host ="smtp.gmail.com"; //"smtp.gmail.com";
user ="[email protected]"; //"[email protected]" // email id to send the emails
pass ="23chennai"; //Your gmail password
String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
String to =temp[1]; // out going email id
String from ="[email protected]"; //Email id of the recipient
String subject ="Link For Download File";
String messageText ="HAI DA MAHI";
boolean sessionDebug = true;
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol.", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.fallback", "false");
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setContent(messageText, "text/html"); // use setText if you want to send text
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, pass);
try {
transport.sendMessage(msg, msg.getAllRecipients());
out.println("message successfully sended"); // assume it was sent
//response.sendRedirect("psendlink.jsp?id="+id+" Message send successfully");
}
catch (Exception err) {
out.println("message not successfully sended"); // assume it’s a fail
}
transport.close();
%>