lib/fluent/plugin/out_mail.rb in fluent-plugin-mail-0.0.5 vs lib/fluent/plugin/out_mail.rb in fluent-plugin-mail-0.1.0

- old
+ new

@@ -22,10 +22,11 @@ config_param :cc, :string, :default => '' config_param :bcc, :string, :default => '' config_param :subject, :string, :default => 'Fluent::MailOutput plugin' config_param :subject_out_keys, :string, :default => "" config_param :enable_starttls_auto, :bool, :default => false + config_param :enable_tls, :bool, :default => false config_param :time_locale, :default => nil def initialize super require 'net/smtp' @@ -90,12 +91,12 @@ messages.each_with_index do |msg, i| subject = subjects[i] begin res = sendmail(subject, msg) - rescue - log.warn "out_mail: failed to send notice to #{@host}:#{@port}, subject: #{subject}, message: #{msg}" + rescue => e + log.warn "out_mail: failed to send notice to #{@host}:#{@port}, subject: #{subject}, message: #{msg}, error_class: #{e.class}, error_message: #{e.message}, error_backtrace: #{e.backtrace.first}" end end chain.next end @@ -159,10 +160,11 @@ smtp = Net::SMTP.new(@host, @port) if @user and @password smtp_auth_option = [@domain, @user, @password, :plain] smtp.enable_starttls if @enable_starttls_auto + smtp.enable_tls if @enable_tls smtp.start(@domain,@user,@password,:plain) else smtp.start end @@ -173,11 +175,11 @@ date = Time::now.timezone(time_locale) else date = Time::now end - smtp.send_mail(<<EOS, @from, @to.split(/,/), @cc.split(/,/), @bcc.split(/,/)) + debug_msg = smtp.send_mail(<<EOS, @from, @to.split(/,/), @cc.split(/,/), @bcc.split(/,/)) Date: #{date.strftime("%a, %d %b %Y %X %z")} From: #{@from} To: #{@to} Cc: #{@cc} Bcc: #{@bcc} @@ -185,10 +187,11 @@ Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 #{body} EOS + log.debug "out_mail: email send response: #{debug_msg}" smtp.finish end end @@ -200,7 +203,5 @@ output = utc.localtime ENV['TZ'] = old output end end - -