@@ -26,6 +26,7 @@ def initialize(info = {})
26
26
[
27
27
OptAddress . new ( "RHOST" , [ true , "The SMTP server to send through" ] ) ,
28
28
OptPort . new ( "RPORT" , [ true , "The SMTP server port (e.g. 25, 465, 587, 2525)" , 25 ] ) ,
29
+ OptString . new ( 'DATE' , [ false , 'Override the DATE: field with this value' , '' ] ) ,
29
30
OptString . new ( 'MAILFROM' , [ true , 'The FROM address of the e-mail' , '[email protected] ' ] ) ,
30
31
OptString . new ( 'MAILTO' , [ true , 'The TO address of the email' ] ) ,
31
32
OptString . new ( 'SUBJECT' , [ true , 'Subject line of the email' ] ) ,
@@ -140,6 +141,19 @@ def send_message(data)
140
141
raw_send_recv ( "MAIL FROM: <#{ datastore [ 'MAILFROM' ] } >\r \n " , nsock )
141
142
raw_send_recv ( "RCPT TO: <#{ datastore [ 'MAILTO' ] } >\r \n " , nsock )
142
143
144
+ # If the user supplied a Date field, use that, else use the current
145
+ # DateTime in the proper RFC2822 format.
146
+ if datastore [ 'DATE' ] . present?
147
+ raw_send_recv ( "Date: #{ datastore [ 'DATE' ] } \r \n " , nsock )
148
+ else
149
+ raw_send_recv ( "Date: #{ DateTime . now . rfc2822 } \r \n " , nsock )
150
+ end
151
+
152
+ # If the user supplied a Subject field, use that
153
+ if datastore [ 'SUBJECT' ] . present?
154
+ raw_send_recv ( "Subject: #{ datastore [ 'SUBJECT' ] } \r \n " , nsock )
155
+ end
156
+
143
157
resp = raw_send_recv ( "DATA\r \n " , nsock )
144
158
145
159
# Avoid sending tons of data and killing the connection if the server
0 commit comments