Lines 20-25
package org.apache.jmeter.protocol.smtp.sampler;
Link Here
|
20 |
import java.io.File; |
20 |
import java.io.File; |
21 |
import java.io.IOException; |
21 |
import java.io.IOException; |
22 |
import java.io.InputStream; |
22 |
import java.io.InputStream; |
|
|
23 |
import java.io.UnsupportedEncodingException; |
23 |
import java.util.ArrayList; |
24 |
import java.util.ArrayList; |
24 |
import java.util.Arrays; |
25 |
import java.util.Arrays; |
25 |
import java.util.Enumeration; |
26 |
import java.util.Enumeration; |
Lines 38-47
import javax.mail.Part;
Link Here
|
38 |
import javax.mail.internet.AddressException; |
39 |
import javax.mail.internet.AddressException; |
39 |
import javax.mail.internet.ContentType; |
40 |
import javax.mail.internet.ContentType; |
40 |
import javax.mail.internet.InternetAddress; |
41 |
import javax.mail.internet.InternetAddress; |
|
|
42 |
import javax.mail.internet.MimeUtility; |
41 |
|
43 |
|
42 |
import org.apache.commons.io.IOUtils; |
44 |
import org.apache.commons.io.IOUtils; |
43 |
import org.apache.commons.io.output.CountingOutputStream; |
45 |
import org.apache.commons.io.output.CountingOutputStream; |
44 |
import org.apache.commons.io.output.NullOutputStream; |
46 |
import org.apache.commons.io.output.NullOutputStream; |
|
|
47 |
import org.apache.commons.lang3.StringUtils; |
45 |
import org.apache.jmeter.config.ConfigTestElement; |
48 |
import org.apache.jmeter.config.ConfigTestElement; |
46 |
import org.apache.jmeter.protocol.smtp.sampler.gui.SecuritySettingsPanel; |
49 |
import org.apache.jmeter.protocol.smtp.sampler.gui.SecuritySettingsPanel; |
47 |
import org.apache.jmeter.protocol.smtp.sampler.protocol.SendMailCommand; |
50 |
import org.apache.jmeter.protocol.smtp.sampler.protocol.SendMailCommand; |
Lines 272-278
public class SmtpSampler extends AbstractSampler {
Link Here
|
272 |
sendMailCmd.setEnableDebug(getPropertyAsBoolean(ENABLE_DEBUG)); |
275 |
sendMailCmd.setEnableDebug(getPropertyAsBoolean(ENABLE_DEBUG)); |
273 |
|
276 |
|
274 |
if (getPropertyAsString(MAIL_FROM).matches(".*@.*")) { |
277 |
if (getPropertyAsString(MAIL_FROM).matches(".*@.*")) { |
275 |
sendMailCmd.setSender(getPropertyAsString(MAIL_FROM)); |
278 |
sendMailCmd.setSender(encodeAddress(getPropertyAsString(MAIL_FROM))); |
276 |
} |
279 |
} |
277 |
|
280 |
|
278 |
// Process address lists |
281 |
// Process address lists |
Lines 368-374
public class SmtpSampler extends AbstractSampler {
Link Here
|
368 |
if (!propValue.isEmpty()) { // we have at least one potential address |
371 |
if (!propValue.isEmpty()) { // we have at least one potential address |
369 |
List<InternetAddress> addresses = new ArrayList<>(); |
372 |
List<InternetAddress> addresses = new ArrayList<>(); |
370 |
for (String address : propValue.split(";")) { |
373 |
for (String address : propValue.split(";")) { |
371 |
addresses.add(new InternetAddress(address.trim())); |
374 |
addresses.add(new InternetAddress(encodeAddress(address))); |
372 |
} |
375 |
} |
373 |
return addresses; |
376 |
return addresses; |
374 |
} else { |
377 |
} else { |
Lines 376-381
public class SmtpSampler extends AbstractSampler {
Link Here
|
376 |
} |
379 |
} |
377 |
} |
380 |
} |
378 |
|
381 |
|
|
|
382 |
private String encodeAddress(String address) throws AddressException { |
383 |
String encodedAddress = address.trim(); |
384 |
if (!StringUtils.isAsciiPrintable(encodedAddress)) { |
385 |
try { |
386 |
final int startOfRealAddress = encodedAddress.indexOf('<'); |
387 |
if (startOfRealAddress >= 0) { |
388 |
String personalPart = encodedAddress.substring(0, startOfRealAddress); |
389 |
encodedAddress = MimeUtility.encodeWord(personalPart) + encodedAddress.substring(startOfRealAddress); |
390 |
} |
391 |
} catch (UnsupportedEncodingException e) { |
392 |
log.warn("Can't encode [{}] as quoted printable", encodedAddress, e); |
393 |
} |
394 |
} |
395 |
return encodedAddress; |
396 |
} |
397 |
|
379 |
/** |
398 |
/** |
380 |
* @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement) |
399 |
* @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement) |
381 |
*/ |
400 |
*/ |
382 |
- |
|
|