Must issue a STARTTLS command first. Sending email with Java and Google Apps

前端 未结 6 2043
傲寒
傲寒 2020-11-30 05:56

I am trying to use Bill the Lizard\'s code to send an email using Google Apps. I am getting this error:

Exception in thread \"main\" javax.mail.SendFailedEx         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 06:40

    I found the problem. Previously i was using j2ee.jar to import javax.mail.

    I removed j2ee.jar from the classpath and downloaded JavaMail 1.4.1 and put into my classpath two jars, smtp.jar and mailapi.jar. I use now smtps instead smtp

    Transport transport = session.getTransport("smtps");            
    

    Now Bill the Lizard's code works.

提交回复
热议问题