0

getting issue com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first trying to send an email from my program to any email. its a just example taken from tutorial but i cant run this example . response is com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first

package test;
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
import java.util.Properties;

public class Main {
  public static void main(String[] args) throws MessagingException {
    String from = "user@some-domain.com";
    String to = "muhammadabdullah0008@gmail.com";
    String subject = "Hi There...";
    String text = "How are you?";

    Properties properties = new Properties();
    properties.put("mail.smtp.host", "smtp.gmail.com");
    properties.put("mail.smtp.port", "25");
    Session session = Session.getDefaultInstance(properties, null);

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
    message.setSubject(subject);
    message.setText(text);

    Transport.send(message);
  }
}

here is the output enter image description here

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • Duplicate of [*JCheckBox value in JTable*](http://stackoverflow.com/q/8739207/230513). – trashgod Jul 31 '16 at 15:45
  • @trashgod Oh I see, the post was edited completely to ask a new question, check [revision 1](http://stackoverflow.com/revisions/38680961/1)... This shouldn't have been done, a new question should have been asked. – Tunaki Jul 31 '16 at 16:54
  • @MuhammadAbdullah Do not radically edit your post like this, if you have a new question, ask a **new** question. – Tunaki Jul 31 '16 at 16:55
  • I edited in this way because I'm blocked to ask new question and older question was still not cleared from already asked question thats why i asked again but some people voted me down . so I've no other option @Tunaki – Muhammad Abdullah Jul 31 '16 at 17:20
  • 1
    Yes, you can improve all of your current questions by clarifying them. Please refer to http://meta.stackexchange.com/questions/86997/what-can-i-do-when-getting-we-are-no-longer-accepting-questions-answers-from-th – Tunaki Jul 31 '16 at 17:21
  • if i'm not cleared from already asked question then what should i do ? – Muhammad Abdullah Jul 31 '16 at 17:22
  • @Tunaki: Thank you; sorry for the spurious ping. – trashgod Jul 31 '16 at 22:00

0 Answers0