# mailer.rb handler doesn't work on my machine

**URL:** <https://discourse.sensu.io/t/mailer-rb-handler-doesnt-work-on-my-machine/392>\
**Category:** Sensu Classic (EOL)\
**Created:** [March 9, 2015, 6:13am UTC](https://discourse.sensu.io/t/mailer-rb-handler-doesnt-work-on-my-machine/392 "2015-03-09T06:13:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothy\_John](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@Timothy\_John](https://discourse.sensu.io/u/Timothy_John)\
**Post date:** [March 9, 2015, 6:13am UTC](https://discourse.sensu.io/t/mailer-rb-handler-doesnt-work-on-my-machine/392/1 "2015-03-09T06:13:51Z")

</div>

I can use **mail** command to send mail to my email address. But I can’t use **mailer.rb** handler to send mails.

I’ve inspect the **sensu-server.log** file, and find these 2 lines of log are suspicious. But I know nothing about Ruby, so I can’t fix it by my own.

{“timestamp”:“2015-03-09T13:38:43.826418+0800”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb -j /etc/sensu/handlers/mailer.json",“name”:“print\_timestamp”},“output”:"/etc/sensu/handlers/mailer.rb:78:in `handle': undefined method`’ for nil:NilClass (NoMethodError)\n"}

{“timestamp”:“2015-03-09T13:38:43.826572+0800”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/mailer.rb -j /etc/sensu/handlers/mailer.json",“name”:“print\_timestamp”},“output”:"\tfrom /var/lib/gems/1.9.1/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:55:in `block in class:Handler’\n"}

Here is my version of **mailer.json** :  
{  
“mailer”: {  
“admin\_gui”: “[http://admin.example.com:8080/](http://admin.example.com:8080/)”,  
“mail\_from”: “neo@matrix.NULL.NULL”,  
“mail\_to”: "xxx@yyy.com",  
“smtp\_address”: “localhost”,  
“smtp\_port”: “25”,  
“smtp\_domain”: “localhost”  
}  
}

About the “ **mail\_from** ” attribute:  
When I use **mail** command send emails, the sender address displayed in the email which I recieved is “neo@matrix.NULL.NULL”, so I use that as a “mail\_from” value. Don’t know whether it’ ok or not.

It seems that SMTP works fine on my machine, I’ve checked it use this command: “telnet localhost 25”. It gives the following result:  
Trying 127.0.0.1…  
Connected to localhost.  
Escape character is ‘^]’.  
220 matrix ESMTP Postfix (Ubuntu)

---

<div class="post-metadata">

**Author:** ![Anthony\_Kong](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anthony\_Kong](https://discourse.sensu.io/u/Anthony_Kong)\
**Post date:** [March 9, 2015, 11:10am UTC](https://discourse.sensu.io/t/mailer-rb-handler-doesnt-work-on-my-machine/392/2 "2015-03-09T11:10:00Z")

</div>

-j does not expect a file path

> **···**
>
> On Monday, 9 March 2015 17:13:51 UTC+11, Timothy John wrote:
> 
> > I can use **mail** command to send mail to my email address. But I can’t use **mailer.rb** handler to send mails.
> > 
> > I’ve inspect the **sensu-server.log** file, and find these 2 lines of log are suspicious. But I know nothing about Ruby, so I can’t fix it by my own.  
> > {“timestamp”:“2015-03-09T13:38:43.826418+0800”,“level”:"  
> > info",“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/etc/sensu/ handlers/mailer.rb -j /etc/sensu/handlers/mailer.json”,“name”:“print\_timestamp”},“output”:“/etc/sensu/ handlers/mailer.rb:78:in `handle': undefined method `’ for nil:NilClass (NoMethodError)\n”}  
> > {“timestamp”:“2015-03-09T13:38:43.826572+0800”,“level”:"  
> > info",“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:“/etc/sensu/ handlers/mailer.rb -j /etc/sensu/handlers/mailer.json”,“name”:“print\_timestamp” },“output”:“\tfrom /var/lib/gems/1.9.1/gems/sensu-plugin-1.1.0/lib/sensu-handler.rb:55:in `block in class:Handler’\n”}
> > 
> > Here is my version of **mailer.json** :  
> > {  
> > “mailer”: {  
> > “admin\_gui”: “[http://admin.example.com:8080/](http://admin.example.com:8080/)”,  
> > “mail\_from”: “neo@matrix.NULL.NULL”,  
> > “mail\_to”: “[x...@yyy.com](mailto:x...@yyy.com)”,  
> > “smtp\_address”: “localhost”,  
> > “smtp\_port”: “25”,  
> > “smtp\_domain”: “localhost”  
> > }  
> > }
> > 
> > About the “ **mail\_from** ” attribute:  
> > When I use **mail** command send emails, the sender address displayed in the email which I recieved is “neo@matrix.NULL.NULL”, so I use that as a “mail\_from” value. Don’t know whether it’ ok or not.
> > 
> > It seems that SMTP works fine on my machine, I’ve checked it use this command: “telnet localhost 25”. It gives the following result:  
> > Trying 127.0.0.1…  
> > Connected to localhost.  
> > Escape character is ‘^]’.  
> > 220 matrix ESMTP Postfix (Ubuntu)
