# Recurring error... 'Cannot open mail:25'

## cgmd

Whenever I review my syslog output, I see a recurring theme represented by the following example:

```
cat  /var/log/messages

May 16 03:00:01 cgmd cron[13160]: (root) CMD (/usr/bin/updatedb^I)

May 16 05:00:01 cgmd cron[13560]: (root) CMD (/usr/bin/emerge --sync)

May 16 05:00:18 cgmd sSMTP[13562]: Unable to locate mail

May 16 05:00:18 cgmd sSMTP[13562]: Cannot open mail:25

May 16 05:05:24 cgmd cron[13559]: (root) MAIL (mailed 151143 bytes of output but got status 0x0001 )
```

I think this is probably harmless information regarding 'mail', but I'm wondering if there is a way to stop this from occurring?

Does anyone have any thoughts about this??

Thanks...

----------

## msalerno

Do you have a  mail server running ?

When your cron daemon is finished running it's tasks, it is sending an email, usually to root.  It's possible that ssmtp cannot open on port 25 because you have another mail server running.

----------

## cgmd

msalerno...

Thanks for responding...

I had attempted to set up samba as a server, but then didn't require it as such and then downgraded it. I have never set up a separate mail server, though (I don't think Mozila Thunderbird qualifies as such).

Any suggestion as to how I could troubleshoot this further??

----------

## msalerno

if you:

# telnet localhost 25

or

# telnet <ipofserver> 25

Do you get a response?

You may need net-misc/netkit-telnetd

----------

## cgmd

msalerno...

I get the following... 

```
 # telnet localhost 25

Trying 127.0.0.1...

telnet: Unable to connect to remote host: Connection refused

```

I'm not sure what to try as an 'ipofserver'?

----------

## msalerno

You would use the inet addr from the output of ifconfig,

I am not 100% sure why this is happening, but I have a few possibilities.

For starters I would look here:

 *Quote:*   

> Unable to locate mail

 

A few things to check, either you are missing the mail package (Doubtful) - mail-client/mailx

Or, your system thinks that it's name is mail, and nowhere does that name point back to the system.

Check the output of

hostname

and

hostname --fqdn

You could also try specifying the hostname in the /etc/ssmtp/ssmtpd.conf

with the line that starts with hostname=

----------

## cgmd

I tried...  *Quote:*   

> Check the output of
> 
> hostname
> 
> and
> ...

 

Both instances returned my correct last name...not 'mail'...

----------

## cgmd

I'll also try adding my hostname to the hostname line in the /etc/ssmtp/ssmtpd.conf.  I'll post the outcome...

Thank you for helping me sort through this!

----------

## cgmd

msalerno...

Thank you, again, for helping with this...

There was no correction of the 'mail' error by adding my hostname to the hostname line in the /etc/ssmtp/ssmtpd.conf.

It appears that the mail request comes from cron activity during the early morning hours:

```
May 17 02:00:01 cgmd cron[12201]: (root) CMD (/usr/sbin/logrotate -s /etc/logrotate.conf)

May 17 02:00:01 cgmd sSMTP[12202]: Unable to locate mail

May 17 02:00:01 cgmd sSMTP[12202]: Cannot open mail:25

May 17 02:00:01 cgmd cron[12200]: (root) MAIL (mailed 296 bytes of output but got status 0x0001 )

May 17 03:00:01 cgmd cron[12400]: (root) CMD (/usr/bin/updatedb^I)

May 17 05:00:01 cgmd cron[12769]: (root) CMD (/usr/bin/emerge --sync)

May 17 05:00:21 cgmd sSMTP[12807]: Unable to locate mail

May 17 05:00:21 cgmd sSMTP[12807]: Cannot open mail:25

May 17 05:05:26 cgmd cron[12768]: (root) MAIL (mailed 140533 bytes of output but got status 0x0001 )

```

If I could redirect to something other than '(root) MAIL', perhaps the output could be satisfied? 

I obviously don't have complete understanding of what's taking place. :Sad: 

----------

## JackBak

I'm in a similar situation with cgmd:

I'm using fcron to do an emerge sync every three days and then it emails the results to

root@my_machine. In the last couple of weeks ( I try to do emerge updates every Saturday

everything stable no ~x86) my fcron emails fail with 

```
send-mail: RCPT TO:<postmaster@my_machine> (550 <postmaster@my_machine> No such user here)
```

I have tried all of this threads suggestions with the same results as cgmd. This has worked great since I set

everything up with fcron about 8 months ago. Obviously, there is a root user which is aliased to postmaster.

In the past the fcron emails would end up in root's dead.letter which is just fine - since there is no real

mail to the outside world -- it's all just ssmtp. Any Ideas?

Thanks.

----------

## cgmd

JackBak...

Please let me know if you find the answer!  :Smile: 

I, too, am starting to use fcron on my laptop, but I'm having trouble figuring out the setup. If your fcron is otherwise working well, any pointers you could share as to how to set it up immediately after emerging it??

Thanks...

----------

## JackBak

cgmd,

I may have led you astray. My fcron still is working (I followed the install tips at fcron's homeoage) but the

gentoo folks decided through some emerge I did that Logwatch was essential. It is logwatch that thinks

it can't email root. The fcron stuff as well as the logwatch stuff (with the err msg about not being

able to email root) ends up where it always has, root's dead.letter file.

So, bottom line -- it all still works I just get this odd logwatch error msg in my dead.letter file. At this

point I'm just ignoring that error msg.

----------

## duden

 *cgmd wrote:*   

> 
> 
> ```
> cat  /var/log/messages
> 
> ...

 

sSMTP tries to send an email through the specified mailhost, in this case host "mail" which is not found. As already mentioned in this thread, you could setup your own local mailserver... but it is easier just to specify the actual mailhost of your domain (usually provided by your ISP). You can define the mailhost in /etc/ssmtp/ssmtp.conf: 

```

mailhub=mailhost.mydomain.com

```

Note that "mailhost" will usually suffice. Also remember to specify the email that should receive the cron output. This is also done i ssmtp.conf:

```

root=duden@myemail.com

```

----------

## drjimmy42

What if I don't want to send the mail anywhere except into my local unix mailspool? I get the same dead.letter files but I just want them to go to /var/spool/root or something.  Any ideas?  Thanks.

----------

## xlulux

 *drjimmy42 wrote:*   

> What if I don't want to send the mail anywhere except into my local unix mailspool? I get the same dead.letter files but I just want them to go to /var/spool/root or something.  Any ideas?  Thanks.

 

i need this awnsered too...

----------

## drjimmy42

This is not the answer to your question but what I did to stop the dead.letters was to use the

```
!mail(false)
```

command in fcron.  This stops it from sending any mail.  I never check my unix spool mail anyway so this is perfect for me.  Still haven't figured the mail out.

----------

## pjp

Moved from Other Things Gentoo

----------

## arnoldbird

It's a very old thread but this issue is caused by the following line in /etc/ssmtp/ssmtp.conf:

mailhub=mail

There is a comment in the config file about this line.

----------

