Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try the given below code to send email, <strong>but use this code into scriptlet &lt;% code goes here %> not in JavaScript or any other client side script function</strong></p> <p>I hope it will work. </p> <pre><code>String host="smtp.gmail.com"; final String user="it1006813052@gmail.com";//change accordingly final String password="wooofqrzcjkjdmlaezr";//change accordingly String to="it1006813052@gmail.com";//change accordingly //Get the session object try { Properties props = new Properties(); props.put("mail.smtp.user",user); props.put("mail.smtp.password", password); props.put("mail.smtp.host", host); props.put("mail.smtp.port", "25"); props.put("mail.debug", "true"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable","true"); props.put("mail.smtp.EnableSSL.enable","true"); props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.setProperty("mail.smtp.socketFactory.fallback", "false"); props.setProperty("mail.smtp.port", "465"); props.setProperty("mail.smtp.socketFactory.port", "465"); Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user,password); } }); //Compose the message try { MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("rohan@bhediya.com")); message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); message.setSubject("whass up?"); message.setText("This is simple program of sending email using JavaMail API"); // add attatchment MimeBodyPart messageBodyPart = new MimeBodyPart(); Multipart multipart = new MimeMultipart(); messageBodyPart = new MimeBodyPart(); String file = "F:/emb3.png"; String fileName = "emb3"; DataSource source = new FileDataSource(file); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(fileName); multipart.addBodyPart(messageBodyPart); message.setContent(multipart); //send the message Transport.send(message); out.println("message sent successfully..."); } catch (MessagingException e) {e.printStackTrace();} } catch(Exception ex) { System.out.println(ex); } </code></pre> <p>you can remove attatchment part if you don't want to attatch anything </p>
    singulars
    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.
    3. 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