Problem In Sending mails
hello friends...
m deepak...
workin on javamail...
m unable to send mails using the javamail....
m using the following code...:
<%@ page import="java.util.Properties"%>
<%@ page import="javax.mail.*" %>
<html>
</body>
<%
String host = "hostname";
String username = "username";
String password = "password";
String Prolocol="IMAP";
// Create empty properties
Properties props = new Properties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session mysession = Session.getDefaultInstance(props, null);
Store store = mysession.getStore("imap");
store.connect(host, username, password);
// Define message
MimeMessage message = new MimeMessage(mysession);
// Set the from address
message.setFrom(new InternetAddress(from));
// Set the to address
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set the subject
message.setSubject("Hello JavaMail");
// Set the content
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
}
}
%>
</body>
</html>
can u help me out...
|