Finding out in-memory size of an email

P

Petr Janda

Hi all,
I have a script that executes sendmail binary like this

exec '/usr/sbin/sendmail'

This opens op the sendmail STDIN that waits for the email to be typed or
inputed via other means(postfix). Is it at all possible to actually
find out the size of the email(in bytes) thats going into sendmail?

Petr
 
B

Brian Candler

Petr said:
I have a script that executes sendmail binary like this

exec '/usr/sbin/sendmail'

This opens op the sendmail STDIN that waits for the email to be typed or
inputed via other means(postfix). Is it at all possible to actually
find out the size of the email(in bytes) thats going into sendmail?

Not sure how this relates to Ruby.

If your ruby script is using 'exec' like that, then it is *replacing*
the entire Ruby interpreter with sendmail. At that point, sendmail is
running, accepting data on stdin, and Ruby has terminated. So sendmail
knows the size of the E-mail, but there is no-one to tell.

Perhaps what you want is to keep Ruby running while sending data to
sendmail, e.g. (untested)

count = 0
IO.popen("/usr/sbin/sendmail","w") do |sendmail|
while data = $stdin.read(4096)
sendmail << data
count += data.size
end
end
STDERR.puts "Thank you. You sent #{count} bytes."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top