Fri, 17 May 2024


How to send an email using javax.mail?

By: Anton, NetArt Media
Sun, 26 July 2020

<%@ 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: Web Development
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox