Ant任务发送电子邮件 - 邮件类型不支持嵌套的“附件”元素。
我正在使用maven来使用TestNG运行测试自动化脚本。我正在使用maven antrun插件在附件中发送带有测试NG报告的电子邮件。
很遗憾,我无法发送附带附件的电子邮件并收到错误
嵌入式错误:邮件> type不支持嵌套的“attachments”元素。
这是我的pom.xml
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<configuration>
<tasks>
<mail
tolist=""
from=""
subject="Report"
mailhost=""
mailport=""
user=""
password="">
<message>Please find the Attached automation report.
Note: This is an automatic generated e-mail
</message>
<attachments>
<fileset dir="target">
<include name="**/*.html"/>
</fileset>
</attachments>
</mail>
</tasks>
</configuration>
<phase>test</phase>
<id>SentEmail</id>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
答案 0 :(得分:1)
您需要将java激活框架和java邮件jar添加到您的 类路径。 它们没有Ant或Java,可以下载here
下载2个罐子,将它们添加到你的ant类路径中,它应该 工作得很好。
答案 1 :(得分:0)
Maven postman插件对我来说很好。谢谢你的帮助。
<plugin>
<groupId>ch.fortysix</groupId>
<artifactId>maven-postman-plugin</artifactId>
<executions>
<execution>
<id>send a mail</id>
<phase>test</phase>
<goals>
<goal>send-mail</goal>
</goals>
<inherited>false</inherited>
<configuration>
<from>xxxxxxxx</from>
<subject>Regression Report</subject>
<failonerror>true</failonerror>
<mailhost>xxxxx</mailhost>
<mailport>xxx</mailport>
<mailuser>xxxxxx</mailuser>
<mailpassword>xxxxx</mailpassword>
<htmlMessage>Please find the Attached automation report.
Note: This is an automatic generated e-mail</htmlMessage>
<receivers>
<receiver>email@email.com</receiver>
</receivers>
<fileSets>
<fileSet>
<directory>${basedir}/target</directory>
<includes>
<include>**/emailable-report.html</include>
<!-- <include>**/*.zip</include> -->
</includes>
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>