D
Diego Bernardes
Hello!
I need to get mails from a mail server using pop3, save to disk to later
resend.
The get part:
pop = Net:OP3.new 'mail server'
pop.start 'address', 'password'
if pop.mails.empty?
puts "No mail"
else
puts "Have mails"
pop.mails.each_with_index do |m,i|
File.open("inbox/#{i}", "w+") do |f|
f.write m.pop
end
end
end
With this code i can download and save the mails into files.
Now i need get this files and resend as mails, this is the part isnt
working...
smtp = Net::SMTP.new 'mail address', port
smtp.start 'mail domain', 'username', 'password', :login
puts smtp.sendmail File.read(file from get path), 'from', 'to'
Well, the send part is broken, can anyone help me?
I need to get mails from a mail server using pop3, save to disk to later
resend.
The get part:
pop = Net:OP3.new 'mail server'
pop.start 'address', 'password'
if pop.mails.empty?
puts "No mail"
else
puts "Have mails"
pop.mails.each_with_index do |m,i|
File.open("inbox/#{i}", "w+") do |f|
f.write m.pop
end
end
end
With this code i can download and save the mails into files.
Now i need get this files and resend as mails, this is the part isnt
working...
smtp = Net::SMTP.new 'mail address', port
smtp.start 'mail domain', 'username', 'password', :login
puts smtp.sendmail File.read(file from get path), 'from', 'to'
Well, the send part is broken, can anyone help me?