Posted By

lmcdougall on 09/13/07


Tagged

mail ruby


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Send Main


 / Published in: Ruby
 

  1. # send email with :login
  2. def send_email(subject, message)
  3.  
  4. from='sender@sender_address.de'
  5. from_alias='the sender'
  6. to='recipient@recip_address.de'
  7. to_alias='the recipient'
  8. smtp_host='smtp.1und1.com'
  9. port=25 # default port is 25
  10. user='username'
  11. password='its_a_secret'
  12.  
  13. myMessage = <<END_OF_MESSAGE
  14. From: #{from_alias} <#{from}>
  15. To: #{to_alias} <#{to}>
  16. Subject: #{subject}
  17.  
  18. #{message}
  19. END_OF_MESSAGE
  20.  
  21. Net::SMTP.start(smtphost, port, from, user, password, :login) do |smtp|
  22. smtp.send_message myMessage, from, to
  23. end
  24. end

Report this snippet  

You need to login to post a comment.