# Memory&Time overload in sending smtp gmail with big attach

**URL:** <https://www.ruby-forum.com/t/memory-time-overload-in-sending-smtp-gmail-with-big-attach/121610>\
**Category:** Ruby\
**Created:** [November 29, 2007, 10:14am UTC](https://www.ruby-forum.com/t/memory-time-overload-in-sending-smtp-gmail-with-big-attach/121610 "2007-11-29T10:14:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollingwoods](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rollingwoods](https://www.ruby-forum.com/u/rollingwoods)\
**Post date:** [November 29, 2007, 10:14am UTC](https://www.ruby-forum.com/t/memory-time-overload-in-sending-smtp-gmail-with-big-attach/121610/1 "2007-11-29T10:14:15Z")

</div>

Recently, I block a gmail sending program(named ‘testsmtp.rb’), with  
ruby1.9 Net::SMTP class(net/smtp.rb renamed to ‘smtpssl.rb’) and a  
custom MAIL BODY builder class (named ‘smtp\_mail\_builder.rb’).

It works well for sending text email with tiny attachments. But, When  
trying to send a 3M .zip attachment in mail, the prg almost used 200M  
memory, and 20 minutes without end.

I guess maybe SSL or SMTP need more appropriate setting for sending big  
attachment mail. It had been out of my ablity.

Anybody can give an advice?

Thanks a lot!

== testsmtp.rb ==================================  
require “smtp\_mail\_builder”  
require “smtpssl”  
require “openssl”

fromName=‘name from’  
fromEMail=‘mail from’  
subject=‘Subject’  
content=‘Content text’  
files=[‘a.zip’]  
to=‘_ **@** _.com’

# build the message

Net::SMTP.enable\_tls(OpenSSL::SSL::VERIFY\_NONE)  
message = Net::SMTP::Message.new(fromName, fromEMail, subject, content)  
files.each do |file|  
message.attachBinaryFile(file)  
end

mailServer= “[smtp.gmail.com](http://smtp.gmail.com)”  
mailUsername= “gmail user name”  
mailPassword= “password for gmail user name”

# send the email

message\_array = message.format(to)  
Net::SMTP.start(mailServer, 587, “localhost.localdomain”, mailUsername,  
mailPassword, :login) do |smtp|  
smtp.sendmail(message\_array, message.fromEMail, to)  
end

===End============================================
