Bug 49775 - Allow sending messages without a body
Allow sending messages without a body
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
unspecified
PC Linux
: P3 enhancement (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-08-18 09:02 UTC by Luciana Moreira
Modified: 2010-09-01 08:15 UTC (History)
1 user (show)



Attachments
patch that allows sending messages without a body (9.51 KB, text/plain)
2010-08-18 09:04 UTC, Luciana Moreira
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luciana Moreira 2010-08-18 09:02:21 UTC
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.
Comment 1 Luciana Moreira 2010-08-18 09:04:43 UTC
Created attachment 25905 [details]
patch that allows sending messages without a body
Comment 2 Sebb 2010-08-19 19:14:29 UTC
Why is the following change needed?

- attach.setDataHandler(new DataHandler(new FileDataSource(f)));
+ attach.setDataHandler(new DataHandler(new FileDataSource(f.getAbsolutePath())));
Comment 3 Sebb 2010-08-20 11:30:19 UTC
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?
Comment 4 Sebb 2010-08-20 15:14:34 UTC
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).
Comment 5 Luciana Moreira 2010-08-25 05:46:12 UTC
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 ;)
Comment 6 Sebb 2010-09-01 08:15:48 UTC
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.