Hi @all,
Hi @all,
i have a problem setting the From: Subject: und To: fields with net::SMTP
i followed an example from the docs and also pickaxe_2 book:
···
---------
Net::SMTP::start('server', 25) do |smtp|
smtp.open_message_stream('ruby-smtp@Webcattest',
[ 'my@email ]
) do |stream|
stream.puts "From: hallo@wach.de"
stream.puts "To: Alle-die-es-angeht"
stream.puts "Subject: Ruby-smtp-TEST"
stream.puts "\nhallo von der Webcatüberwachung mit Ruby! \n\n"
stream.puts "ErrorCode:"
stream.puts error_code
stream.puts "\n\nErrorMessage:"
stream.puts error_message
end
end
-----------
Output:
Email-Body:
#####
From: Ruby WebCat ALERT
To: Alle-die-es angeht
Subject: Ruby-smtp-TEST
hallo von der Webcatüberwachung mit Ruby!
ErrorCode:
404
ErrorMessage:
/notvalidurl
#####
i expected to see the Subject of the message not in the Email-Body, but in
the header to display it in my email-client.
This method (also from the docs) works (Sets the Subject correctly), but
here i can't put values of variables into the message text (as i can see it)
--------------
msgstr = <<END_OF_MESSAGE
From: Your Name <your@mail.address>
To: Destination Address <my@email.de>
Subject: test message
This is a test message.
END_OF_MESSAGE
Net::SMTP.start('exchange2000', 25) do |smtp|
smtp.send_message msgstr, 'Ruby-smtp@test.de', 'myname@hallo.de'
end
--------------
Could i either change the first method to set the subject or the second to
include my variable-values?
I'm just beginning with ruby so any hints are welcome.
Best Regards,
Torsten