Ich habe das gleiche in Ruby gemacht. Python3: E-Mail mit Starttls senden Ich habe es auf hi-ho.ne.jp versucht.
Bibliotheksinstallation
sudo gem install mail
hi-ho.rb
#! /usr/bin/ruby
# -*- encoding: utf-8 -*-
#
# hi-ho.rb
#
# Jul/08/2020
#
# ---------------------------------------------------------------------
require "mail"
require "dotenv"
STDERR.puts "***Start***"
Dotenv.load
server = ENV['SERVER']
port = ENV['PORT']
usr = ENV['USR']
password = ENV['PASSWORD']
from = ENV['FROM']
to = ENV['TO']
#
puts server
puts port
str_out = "Good Morning\n"
str_out += "Hallo.\n"
str_out += "Jul/08/2020\n"
str_out += "PM 15:58\n"
mail = Mail.new do
from from
to to
subject "Hello from Hi-ho PM 15:58"
content_type 'text/plain; charset=UTF-8'
body str_out
end
mail.delivery_method(:smtp,
address: server,
port: port,
authentication: :login,
us
er_name: usr,
password: password
)
mail.deliver
STDERR.puts "***Ende***"
# ---------------------------------------------------------------------
.env
SERVER = 'hi-ho.mose-mail.jp'
PORT = 587
USR = '****@hi-ho.ne.jp'
PASSWORD = '****'
FROM = '****@hi-ho.ne.jp'
TO = '[email protected]'
Ausführungsergebnis
$ ./hi-ho.rb
***Start***
hi-ho.mose-mail.jp
587
***Ende***
Ich habe es in der nächsten Version bestätigt.
$ ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
Recommended Posts