groovy - 在 Apache JMeter 中发送带有多个附件的电子邮件的 GROOVY 脚本
问题描述
我正在使用 Apache JMeter 加载测试电子邮件。我尝试使用简单的 SMTP 采样器,但由于某种未知原因它失败了(无法将套接字转换为 tls)
所以我使用了一个 groovy 脚本并将其放入 JSR223 采样器中。为了实现它,我首先下载了 2 个 JAR 文件并将其添加到“lib”文件夹中。
JAR 文件是:
- 简单的java-mail-5.1.3.jar
- 电子邮件地址-rfc2822-1.1.2.jar
将这些 JAR 文件添加到 lib 文件夹后,我将以下代码放入采样器中:
import org.simplejavamail.email.Email
import org.simplejavamail.email.EmailBuilder
import org.simplejavamail.mailer.Mailer
import org.simplejavamail.mailer.MailerBuilder
import org.simplejavamail.mailer.config.TransportStrategy
Mailer mailer = MailerBuilder
.withTransportStrategy(TransportStrategy.SMTP_TLS)
.withSMTPServer("outlook.office365.com", 587)
.withSMTPServerUsername("jitender.singh@outlook.com")
.withSMTPServerPassword("*******")
// .withProxyHost("replace with your proxy host")
// .withProxyPort(1234) // replace with your proxy port
// .withProxyUsername("your proxy username if needed")
// .withProxyPassword("your proxy password if needed")
.buildMailer()
Email email = EmailBuilder.startingBlank()
.from("jitender.singh@outlook.com")
.to("test@outlook.com")
.withSubject("test subject")
.withPlainText("test message")
.buildEmail()
mailer.sendMail(email)
此设置有效。
我需要帮助的是修改上面的代码,以便我可以在每封电子邮件中发送 3 个附件。
有人可以帮我吗?
我正在使用 Apache JMeter 5.4.1
解决方案
你可以利用SMTP Sampler
. 我可以根据您的要求提供所有选项,包括附加多个文件。
有关详细信息,请参阅此处:https ://www.blazemeter.com/blog/load-testing-your-email-server-how-send-and-receive-e-mails-jmeter
推荐阅读
- google-chrome-extension - Chrome扩展浏览器动作图标查询
- javascript - 将垫表值与标题文本对齐,角度材料
- mailto - 是否可以通过 Apaptive 卡上的 Action.OpenUrl 在 mailto 中指定多个收件人
- c++ - 构造函数初始化列表不遵循顺序
- php - 在 Laravel 8 中从用户名创建自定义图像
- laravel - Laravel Fortify XHR 登录响应
- sql - 跟踪下单时公司收入的变化,分流派
- python - 混合日期格式更新
- django - Django admin super_user 和普通用户权限
- kubernetes - Istio:单个网关和多个 VirtualServices(每个都在不同的命名空间中)