« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

send mail with :login

// with ":login" you authenticate with user and password
// more info: Library Net:SMTP [Dave Thomas, The Pragmatc Programmer]
  # send email with :login
  def send_email(subject, message)
   
    from='sender@sender_address.de'
    from_alias='the sender'
    to='recipient@recip_address.de'
    to_alias='the recipient'
    smtp_host='smtp.1und1.com'
    port=25   # default port is 25
    user='username'
    password='its_a_secret'

    myMessage = <<END_OF_MESSAGE
From: #{from_alias} <#{from}>
To: #{to_alias} <#{to}>
Subject: #{subject}

#{message}
END_OF_MESSAGE

    Net::SMTP.start(smtphost, port, from, user, password, :login) do |smtp|
      smtp.send_message myMessage, from, to
    end
  end
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed