sending the simplest of emails? (ruby or RoR)
(newbe)
Am I missing something very basic, what does it take for me to send a simple email with 'hello' to my personal inbox in ruby (or Rails)
in php it's this simple : mail("someone@example.com","My subject",$msg);
I know php has to be running from a server to able to do anything, but what would I need to get the equivalent in ruby (or rails?) from my local computer?
I tried the Rails Guides Action mailer basics only to be rewarded with output in the terminal :(
...or copy and paste the following from https://www.tutorialspoint.com/ruby/ruby_sending_email.htm
with the following code running in a test_email.rb file and execute with $ruby test_email.rb
require 'net/smtp'
message = <
From: Private Person
To: A Test User
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::SMTP.start('localhost') do |smtp|
smtp.send_message message, 'me@fromdomain.com', 'my_personal_email_here@me.com'
end
Returns this :
/Users/me/.rbenv/versions/2.7.2/lib/ruby/2.7.0/net/smtp.rb:539:in `initialize': Connection refused - connect(2) for "localhost" port 25 (Errno::ECONNREFUSED)
(Can that only run from a server?)
It's looking for an SMTP server running on your machine on port 25. You'd have to run something like postfix to do that.