Similar to bug 49622 I have created a patch to send messages without a body. The patch enhances the functionality of the SMTP Sampler in JMeter. This patch is attached, and consists of a simple check box to determine if the body should be empty or not.
Created attachment 25905 [details] patch that allows sending messages without a body
Why is the following change needed? - attach.setDataHandler(new DataHandler(new FileDataSource(f))); + attach.setDataHandler(new DataHandler(new FileDataSource(f.getAbsolutePath())));
Also, I get java.io.IOException: No content if the message body is suppressed and there are no attached files. Perhaps the checkbox should only be enabled if there is at least one file?
If there is no body and no files, it looks like the code needs to do the following to avoid the error: message.setText(""); This results in an empty body, with the headers: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I assume that this is what you were aiming for? == Given that it might be useful to send SMTP messages which are not multipart/mixed, maybe it would be better to change the code so that if the flag is set then the code uses: message.setText(mailBody) This would only make sense if there were no files. Though if the mailBody was emtpy, perhaps one could allow a single file and send that as the body. If you think this makes sense, I'm happy to make the changes (i.e. no need for you to redo the patch).
Sebb this week I am quite busy, but I will do my best to get back to you on these topics next week. Good to see that you are looking into it ;)
Applied patch to SVN with some changes as described: URL: http://svn.apache.org/viewvc?rev=991510&view=rev Log: Bug 49775 - Allow sending messages without a body Modified: jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java jakarta/jmeter/trunk/xdocs/changes.xml jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Please re-open the bug if there are any issues with the changes.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2393