From logstash i need to send email to gmail

Hi,

I have to send the email from my logstash. my configuration is , What are the prerequisites to achieve the requirement apart from the below configuration.

email {

	to => 'xyz@gmail.com'
	via => 'smtp'
	address => 'smtp.gmail.com'
	from => 'xyz@gmail.com'
	subject => 'Alert - %{title}'
	body => "Tags: %{tags}\\n\\Content:\\n%{message}"
	port => 25
	use_tls => false

}

For your reference in my logstash machine doesn't have mail server,
when i execute the below command in my machine it doent connect the gmail smtp
command is telnet "smtp.gmail.com 587"

error is "Could not open connection to the host, on port 587: Connect failed"

Thanks in Advance,
Suganth a

Well, if you can't connect to smtp.gmail.com:587 then you can't send email via Gmail. IIRC the email output uses STARTTLS rather than SMTPS, otherwise SSL over port 465 would've been an option.

Thanks Magnusbaeck, With the help of network admin I am receiving the following response for the command "telnet smtp.gmail.com 587"
Response is
"220 smtp.gmail.com ESMTP 77sm680281pfz.47 - gsmtp"

Than i tried to send a mail but i got the error as
"[logstash.outputs.email ] Something happen while delivering an email {:exception=>#<Net::SMTPAuthenticationError: 530-5.5.1 Authentication Required. Learn more at" Could you please help me to solve this.

Thanks Magnus, Now it worked for me but the error message is not going as email.. instead the IF condition alone going as a body in my mail my configuration is
**
if "Eligibility Overruled.." in [message] {
email {

	to => 'xyz@gmail.com'
	codec => "plain"
	debug => 'true'
	via => 'smtp'
	address => 'smtp.gmail.com'
	username => 'xyz@gmail.com'
	password => 'xyz'
	subject => 'Alert - %{title}'
	body => '%{message}'
	port => 25
	use_tls => true

}
}**

From the above cofiguration i can receive the message in my mail as Eligibility Overruled.. but i need full error message.

Thanks,
Suganth A

I don't quite understand. The configuration above should give you an email with the full text of the message field. Is that not enough? If so, where is the rest of the information you want?

No Magnus its not giving the full text if message field instead it giving the text what i have used for IF condition that is giving as message, based on the above configuration am receiving the message as Eligibility Overruled…

Thanks,
Suganth A

I find that very hard to believe. If you change the condition to be if "Eligibility Over" in [message], does the email contents change accordingly?

Its my mistake magnus, in the message it gets the actual error message alone and sending the error , I didn't understand properly, Thanks boss.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.