Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

Example SMTP Scripts

 

Topic Last Modified: 2007-01-24

The following SMTP commands are described in RFC 821 (see http://www.ietf.org):

HELO
EHLO
QUIT
DATA
BDAT
MAIL
RCPT
AUTH
STARTTLS
VRFY
RSET

The following script commands are defined by this module:

  • CONNECT   Attempts to establish an SMTP socket connection.
  • DATASTRING   Indicates that the given argument should be interpreted as a literal string and transmitted (during the DATA command). Can be used to transmit message headers.
  • DATAFILE   Indicates the given argument should be interpreted as the name of a file and that the contents of the file should be transmitted (during the DATA command).
  • DATAEND   Indicates that all message contents have now been transmitted, and a response from the server is to be expected. An example is Scripts.

Send a message that has one recipient. The message body is in file body.txt. Sleep between 3 and 5 seconds afterward.

CONNECT
EHLO
MAIL FROM: <me>
RCPT TO: someone@somewhere
DATA body.txt
QUIT
SLEEP RANDNUMBER(3000, 5000)
noteNote:
body.txt ends with CRLF.CRLF. You can also use BDAT instead of DATA.

Send a message that has a random number of recipients. Each recipient has a random name and a random domain. Each message has a random body file.

CONNECT
EHLO
MAIL FROM: <me>
LOOP RANDNUMBER(100, 1000)
RCPT TO: rcptRANDNUMBER(1, 20)@RANDLIST(domains.txt)
ENDLOOP
DATA RANDLIST(bodies.txt)
QUIT

Where: domains.txt contains the domains to chose from (one domain per line), and bodies.txt contains the file names to chose from (one line name per line).

Each file listed in bodies.txt ends with CRLF.CRLF. You can also use BDAT instead of DATA. Each recipient name is in the form: rcptX, where X is a number between 1 and 20.

Send a message that has headers generated programmatically.

CONNECT
EHLO
MAIL FROM: <me>
RCPT TO: <you>
DATA
DATASTRING From: me\nTo: you\n
DATASTRING Subject: test message #SEQUNUMBER(1, 100000, 10)\n
DATASTRING X-MsgId: SAMESEQUNUMBER(1, 100000, 10)\n\n
DATAFILE <chunk1.txt>
DATAFILE <chunk2.txt>
DATASTRING \n.\n
ENDDATA
QUIT

Neither chunk1.txt nor chunk2.txt contains the sequence CRLF.CRLF. In this example, the ending sequence is sent explicitly. BDAT does not support this format.

Send a message on a secure line and authenticate.

CONNECT
EHLO
STARTTLS
AUTHENTICATE user "password"
MAIL FROM: <me>
RCPT TO: <you>
DATA body.txt
QUIT

The user name and password can be unquoted if they consist of only one word. An empty password is represented as “”.

 
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.