LoadRunner and its non-standard SMTP implementation

In one of my recent assignments I was asked to investigate how the SMTP vuser type behaves in LoadRunner. The need was to send alot of EMail messages to a SMTP server, and specifically the CC and BCC fields where important.

As it turns out the SMTP implementation in LoadRunner (v8.1 and v9.5x) does not quite follow the standard when it comes to the CC and BCC headers.To actually test the SMTP script I first had to get myself a SMTP Dummy server (so I could send something somewhere) and after evaluating several free ones, I decided to write my own. The main reason was that now I had control over the server end too making debugging much easier.

So to test the SMTP Client implementation I took the code from the LR help file and modified it slightly to suit my needs.

 // Connect to MailServer
 "CommonName=Smtp Test User 0001",
 LAST );

 // Send an EMail
 "Subject=Testing SMTP From LR",
 "X-Priority: 3",
 "X-MSMail-Priority: Normal",
 "X-Mailer: Microsoft Outlook Express 5.00.2919.6700",
 "X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700",
 "MessageText=This is a simple mail from LR\r\n",
 LAST );

 // Wait a sec

 // Disconnect from Server

 return 0;

Too see what was really going on at the protocol level I used WireShark to capture the traffic to my dummy server:

220 Celarius Dummy SMTP Server v1.0 Beta
EHLO CliMachine
250-Hello CliMachine
250-SIZE 0
MAIL FROM: lr@domain.com
250 2.1.0 lr@domain.com Address Okay
RCPT TO: <TO@domain.com>
250 2.1.5 TO@domain.com Address Okay
RCPT TO: <CC@domain.com>
250 2.1.5 CC@domain.com Address Okay
RCPT TO: <BCC@domain.com>
250 2.1.5 BCC@domain.com Address Okay
354 Start mail input; end with <CRLF>.<CRLF>
Message-ID: <00004b49b60c$00000001$01401408@>
From: "Smtp Test User 0001"
Date: Sun, 10 Jan 2010 13:12:12 +02:00
Subject: Testing SMTP From LR
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2919.6700
X-MieOLE: Produced By Microsoft MimeOLE V5.00.2919.6700

This is a simple mail from LR

250 Ok
221 Signing Off

Now from the raw log I can clearly see that all the recipients email addresses are sent using the RCPT TO command, but the actual mail-headers do not contain the TO, CC or BCC headers as expected. This will in effect render the built-in SMTP implementation totally useless for any serious testing of a mail server.

The only way I could get the headers to appear in the email-headers was to manually add them in the MAILOPTIONS part, thus making my code more complicated.

The other solution I came up with was to create a SMTPClient.DLL extension, that implements the SMTP protocol correctly, and also gives me the possibility to test SSL or TLS authenticated servers, but that is another story that I might blog about in the future…


2 thoughts on “LoadRunner and its non-standard SMTP implementation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s