diff --git a/lib/simpleMailer.rb b/lib/simpleMailer.rb index 4dbdea3..c1cc208 100644 --- a/lib/simpleMailer.rb +++ b/lib/simpleMailer.rb @@ -52,6 +52,10 @@ def attach_files(files) self end + def addr(field) + return field.gsub(/[^<]*<([^>]*)>/, '\1') + end + def generate_file_part(file) b64file=String.new filename=File.basename(file) @@ -96,7 +100,8 @@ def send() Net::SMTP.start(@host,@port) do |smtp| begin generate_body - smtp.send_message(@body,@from,@to) + to = @to.map { |t| addr(t) }.join(', ') + smtp.send_message(@body,addr(@from),to) return true rescue => e e