apacheant邮件任务和STARTTLS

时间:2012-09-13 14:15:28

标签: java ant automation javamail

每次有人运行apacheant更新我们的实时服务器时,我都会尝试向我的团队发送电子邮件,我正在尝试通过GMAIL发送电子邮件,但是当我运行时,ant upload_live -d我收到以下错误,

BUILD FAILED /Users/simon/Documents/websites/apacheant/build.xml:116: Problem while
     

发送mime邮件:           在org.apache.tools.ant.taskdefs.email.MimeMailer.send(MimeMailer.java:241)           在org.apache.tools.ant.taskdefs.email.EmailTask​​.execute(EmailTask​​.java:577)           在org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)           at sun.reflect.GeneratedMethodAccessor4.invoke(未知来源)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)           在java.lang.reflect.Method.invoke(Method.java:597)           在org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)           at org.apache.tools.ant.Task.perform(Task.java:348)           在org.apache.tools.ant.Target.execute(Target.java:390)           在org.apache.tools.ant.Target.performTasks(Target.java:411)           在org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)           在org.apache.tools.ant.Project.executeTarget(Project.java:1368)           at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)           在org.apache.tools.ant.Project.executeTargets(Project.java:1251)           在org.apache.tools.ant.Main.runBuild(Main.java:809)           在org.apache.tools.ant.Main.startAnt(Main.java:217)           在org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)           在org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)引起   by:com.sun.mail.smtp.SMTPSendFailedException:530 5.7.0必须发出一个   首先是STARTTLS命令。 dp8sm20701038wib.3

    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at org.apache.tools.ant.taskdefs.email.MimeMailer.send(MimeMailer.java:239)
    ... 17 more

我的目标定义如下所示,

<mail enableStartTLS="true" ssl="no" mailhost="smtp.gmail.com" mailport="587" user="apache.ant.alert@gmail.com" password="*********" subject="${project} Pushed Live">
        <from address="apache.ant.alert@gmail.com"/>
        <replyto address="apache.ant.alert@gmail.com"/>
        <to address="simon@"/>
        <cc address="andrew@" />
        <message>${project} has successfully been transferred via FTP.</message>
    </mail>
    <echo>Mail Sent</echo>

我做错了什么?

1 个答案:

答案 0 :(得分:2)

我用以下内容对其进行了排序,

<mail enableStartTLS="true" ssl="true" mailhost="smtp.gmail.com" mailport="465" user="apache.ant.alert@gmail.com" password="******" subject="${project} Pushed Live">
        <from address="apache.ant.alert@gmail.com"/>
        <replyto address="apache.ant.alert@gmail.com"/>
        <to address="simon@"/>
        <cc address="andrew@" />
        <message>${project} has successfully been transferred via FTP.</message>
    </mail>