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

**URL:** <https://rubytalk.org/t/memory-time-overload-in-sending-smtp-gmail-with-big-attach/42601>\
**Category:** ruby-talk\
**Created:** [29 November 2007 09:14 UTC](https://rubytalk.org/t/memory-time-overload-in-sending-smtp-gmail-with-big-attach/42601 "2007-11-29T09:14:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rk\_Ch](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@Rk\_Ch](https://rubytalk.org/u/Rk_Ch)\
**Post date:** [29 November 2007 09:14 UTC](https://rubytalk.org/t/memory-time-overload-in-sending-smtp-gmail-with-big-attach/42601/1 "2007-11-29T09:14:12Z")

</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|  
&nbsp;&nbsp;&nbsp;&nbsp;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|  
&nbsp;&nbsp;&nbsp;&nbsp;smtp.sendmail(message\_array, message.fromEMail, to)  
end

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

Attachments:  
[http://www.ruby-forum.com/attachment/1055/gmailsender.zip](http://www.ruby-forum.com/attachment/1055/gmailsender.zip)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
