Hi,

the following function to mail with an attachment is not working, mail
is going but Its not attaching the file:

send_mail(file_attach, mail_to, password, to, from)

  filename = file_attach
  filecontent = File.read(filename)
  encodedcontent = [filecontent].pack("m") # base64
  marker = "AUNIQUEMARKER"
  body =<<EOF
Mail body

Thank you,
Proggrammer
EOF

part1 =<<EOF
From: #{from}
To:  #{to}
Subject: test subject
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=#{marker}
--#{marker}
EOF

part2 =<<EOF
#{body}
EOF

part3 =<<EOF
Content-Type: multipart/mixed; name=\"#{filename}\"
Content-Transfer-Encoding:base64
Content-Disposition: attachment; filename="#{filename}"
#{encodedcontent}
--#{marker}--
EOF

  mailtext = part1 + part2 + part3

  begin
    Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
    Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', from, password,
:login) do |smtp|
      smtp.send_message(mailtext, from, mail_to)
    end
  rescue Exception => e
    print "Mailing exception occured: " + e
  end
end

After this, how can I send multiple attachment, suppose files to attach
are in array 'a_array'?

-- 
Posted via http://www.ruby-forum.com/.