Memory&Time overload in sending smtp gmail with big attach

R

Rk Ch

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"
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============================================

Attachments:
http://www.ruby-forum.com/attachment/1055/gmailsender.zip
 

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,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top