Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The complete code to send email from Yahoo using JavaMail API as below:</p> <pre><code>package ripon.java.mail; import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class SendFromYahoo { public static void main(String [] args) { // Sender's email ID needs to be mentioned String from = "test123@yahoo.com"; String pass ="test123"; // Recipient's email ID needs to be mentioned. String to = "riponalwasim@yahoo.com"; String host = "smtp.mail.yahoo.com"; // Get system properties Properties properties = System.getProperties(); // Setup mail server properties.put("mail.smtp.starttls.enable", "true"); properties.put("mail.smtp.host", host); properties.put("mail.smtp.user", from); properties.put("mail.smtp.password", pass); properties.put("mail.smtp.port", "587"); properties.put("mail.smtp.auth", "true"); // 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 transport = session.getTransport("smtp"); transport.connect(host, from, pass); transport.sendMessage(message, message.getAllRecipients()); transport.close(); System.out.println("Sent message successfully...."); }catch (MessagingException mex) { mex.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload