/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { // Recipient's email ID needs to be mentioned. // Sender's email ID needs to be mentioned // Assuming you are sending email from localhost // Get system properties // Setup mail server properties.setProperty("mail.smtp.host", host); // Get the default Session object. Session session = Session.getDefaultInstance(properties); try{ // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(from)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); // Set Subject: header field message.setSubject("This is the Subject Line!"); // Now set the actual message message.setText("This is actual message"); // Send message Transport.send(message); }catch (MessagingException mex) { mex.printStackTrace(); } } }
Standard input is empty
Main.java:28: error: cannot find symbol Session session = Session.getDefaultInstance(properties); ^ symbol: class Session location: class Ideone Main.java:28: error: cannot find symbol Session session = Session.getDefaultInstance(properties); ^ symbol: variable Session location: class Ideone Main.java:32: error: cannot find symbol MimeMessage message = new MimeMessage(session); ^ symbol: class MimeMessage location: class Ideone Main.java:32: error: cannot find symbol MimeMessage message = new MimeMessage(session); ^ symbol: class MimeMessage location: class Ideone Main.java:35: error: cannot find symbol message.setFrom(new InternetAddress(from)); ^ symbol: class InternetAddress location: class Ideone Main.java:38: error: package Message does not exist message.addRecipient(Message.RecipientType.TO, ^ Main.java:39: error: cannot find symbol new InternetAddress(to)); ^ symbol: class InternetAddress location: class Ideone Main.java:48: error: cannot find symbol Transport.send(message); ^ symbol: variable Transport location: class Ideone Main.java:50: error: cannot find symbol }catch (MessagingException mex) { ^ symbol: class MessagingException location: class Ideone 9 errors
Standard output is empty