<?xml version="1.0" encoding="utf-8"?> <project name="pc" default="all" basedir="D:\jmeter-5.4"> <tstamp> <format property="time" pattern="yyyyMMddhhmm" /> </tstamp> <!-- Need to change to your own local Jmeter directory - > <property name="jmeter.home" value="D:\jmeter-5.4" /> <! -- path to jmeter to generate result reports in jtl format -- > <property name="jmeter.result.jtl.dir" value="D:\jmeter-5.4\test\resultlog\jtl" /> <! -- Path to the html formatted result report generated by jmeter -- > <property name="jmeter.result.html.dir" value="D:\jmeter-5.4\test\resultlog\html" /> <! -- the prefix of the generated report--> <property name="ReportName" value="TestReport" /> <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" /> <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${test}${time}.jtl" /> <!-- E-mail address for receiving test reports --> <property name="mail_from" value="[email protected]" /> <property name="mail_to" value="[email protected]" /> <!-- Computer Address --> <!-- <property name="ComputerName" value="jkqsh-l0285" />--> <target name="all"> <antcall target="test" /> <antcall target="report" /> <antcall target="sendmail" /> </target> <target name="test"> <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" /> <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}"> <!-- Declare the scripts to be run." *.jmx" means all jmeter scripts in this directory --> <testplans dir="D:\jmeter-5.4\test\script" /> </jmeter> </target> <path id="xslt.classpath"> <fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/> <fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/> </path> <target name="report"> <xslt classpathref="xslt.classpath" force="true" in="${jmeter.result.jtlName}" out="${jmeter.result.htmlName}" style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl"> <param name="dateReport" expression="${time}"/> </xslt> <!-- Because the above report generation will not copy the related images to the target directory, so you need to copy them manually --> <copy todir="${jmeter.result.html.dir}"> <fileset dir="${jmeter.home}/extras"> <include name="collapse.png" /> <include name="expand.png" /> </fileset> </copy> </target> <!-- send files --> <target name="sendmail" > <mail mailhost="smtp.163.com" mailport="994" ssl="true" user="${mail_from}" password="xxx" subject="Interface Test Report" from="${mail_from}" > <to address="${mail_to}"/> <message>For a detailed report, please see the attachment</message> <attachments> <fileset dir="${jmeter.result.html.dir}"> <include name="${ReportName}${time}.html"/> </fileset> </attachments> </mail> </target> </project>
Solution:
Call 163 mailbox server to send mail. We need to start POP3/SMTP service. At this time, 163 mail will let us set the client authorization code. This authorization code can successfully send mail by replacing passwd
in the code part above