×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

JAVA example - How to send an email using javax.mail?


JAVA - How to send an email using javax.mail?

<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
         
<%
Properties props = new Properties();
props.put("mail.smtp.host", "mailserver.com");
Session s = Session.getInstance(props,null);


InternetAddress from = new InternetAddress("mail@mail.com");
InternetAddress to = new InternetAddress(recepeint@server.com");  

MimeMessage message = new MimeMessage(s);
message.setFrom(from);
message.addRecipient(Message.RecipientType.TO, to);
   
message.setSubject("Your subject");
message.setText("Your text");
Transport.send(message);


%>

Category: JAVA

 
<< Go back