"must issue starttls command first"...What does this mean?
I'm trying to send a virus report through antivir, and it comes up with the message: Error message received by smtp server 530 5.7.0 Must issue a STARTTLS command first 32sm15115633aga. I am using gmail smtp. How do I fix this? Where do I put this code? I am a complete newbie at this. Can I have more details please?
Public Comments
- i have gmail also but i have no idea how to fix this
- Hello Here is my code that will connect and send an email via gmail. Hope it helps! The problem most likely is that you're doing the security (SSL) the wrong way. Good luck! ^^ import javax.mail.*; import javax.mail.internet.*; import java.util.*; public class Main { String d_email = "ADDRESS@gmail.com", d_password = "PASSWORD", d_host = "smtp.gmail.com", d_port = "465", m_to = "EMAIL ADDRESS", m_subject = "Testing", m_text = "Hey, this is the testing email."; public Main() { Properties props = new Properties(); props.put("mail.smtp.user", d_email); props.put("mail.smtp.host", d_host); props.put("mail.smtp.port", d_port); props.put("mail.smtp.starttls.enable","true"); props.put("mail.smtp.auth", "true"); //props.put("mail.smtp.debug", "true"); props.put("mail.smtp.socketFactory.port", d_port); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); SecurityManager security = System.getSecurityManager(); try { Authenticator auth = new SMTPAuthenticator(); Session session = Session.getInstance(props, auth); //session.setDebug(true); MimeMessage msg = new MimeMessage(session); msg.setText(m_text); msg.setSubject(m_subject); msg.setFrom(new InternetAddress(d_email)); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to)); Transport.send(msg); } catch (Exception mex) { mex.printStackTrace(); } } public static void main(String[] args) { Main blah = new Main(); } private class SMTPAuthenticator extends javax.mail.Authenticator { public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(d_email, d_password); }
Powered by Yahoo! Answers