# sendmail can't open the SMPT port

## glober

I just got my gentoo running and after a few stumbles I have most things running OK.  One nagging thing I haven't been able to figure out is why I keep getting the following message:

     /usr/sbin/sendmail: can't open the SMPT port (25) on mail.

My installation was from a K6-2 stage 3 tarball, and I chose to install metalog and vcron. After that I emerged X and KDE.  The thing is I never installed sendmail nor do I want to.  I looked at the various scripts in the /etc directory but I just can't figure out what is causing this message.  Not that it's 

causing any harm,  it is kinda annoying.

----------

## prberens

It is cron.  To disable cron trying to send an email after each run (hourly), put MAILTO="" at the top of your crontab.

----------

## lx

With fcron I use !mail(false) at the top of my crontab file, but I don't know the option for vcron.

Cya lX.

----------

## rac

Moving from Installing to Networking.

----------

## glober

 *prberens wrote:*   

> It is cron.  To disable cron trying to send an email after each run (hourly), put MAILTO="" at the top of your crontab.

 

Tried what you suggested but I still keep getting the message

----------

## glober

 *lx wrote:*   

> With fcron I use !mail(false) at the top of my crontab file, but I don't know the option for vcron.
> 
> Cya lX.

 

Tried your suggestion as well and I still get the message

----------

## col

find the command in cron.hourly or wherever it is and pipe it to /dev/null like:

/usr/bin/webalizer 1> /dev/null 2> /dev/null

----------

## fyerk

 *col wrote:*   

> find the command in cron.hourly or wherever it is and pipe it to /dev/null like:
> 
> /usr/bin/webalizer 1> /dev/null 2> /dev/null

 

The easier way to do this is to just send stdout to /dev/null and redirect stderr to stdout

```

/usr/bin/webalizer > /dev/null 2>&1

```

----------

## lx

Well maybe the first question should be, is this problem related to the cron service. Have you determined already what proces is causing the message? (recurring event, when / starting stoping services, etc).

Maybe we're blaiming cron (although it's a good candidate), but it might be something else,

Cya lX.

----------

## glober

 *lx wrote:*   

> Well maybe the first question should be, is this problem related to the cron service. Have you determined already what proces is causing the message? (recurring event, when / starting stoping services, etc).
> 
> Maybe we're blaiming cron (although it's a good candidate), but it might be something else,
> 
> Cya lX.

 

Looking at the various crons (hourly,daily,weekly,monthly) they are all empty, as I haven't put anything in there, nor am I too fluent on the needs of what one should have in there.  

I do not see the command  " /usr/bin/webalizer " in any of the crons.

The message recurrs about every 15 to 20 minutes, so it doesn't look like it would be caused by the hourly cron. As far as seeing whether it coincides with any action or event, it doesn't seem to, it seems to happen all by itself.  One thing I should add, is that it only happens in the initial command line terminal window, so I notice it only if I don't start X or after I do a shutdown, which is when I see how many times the message occured.

Over all, my system is a fairly basic setup like I described in my original message, I do not have sendmail installed, and I didn't do any weird tweeking.  

I am suprised that I didn't find any reference to this quirk in any of the forums.

----------

## Jeff In Motion

I'm having the same exact problem.  I just did a fresh 1.4_rc1 install, and about every 20 minutes or so I get this message.

```
/usr/sbin/sendmail: can't open the smtp port (25) on mail.
```

I too am using vcron.

I've done some searches around the board on this issue, and it remains ultimately unsolved (for me at least).  The two possible solutions seem to be either a) correctly configure /etc/ssmtp/ssmtp.conf  -- or b) install postfix

Well unfortunately, I never use sendmail, and the only thing I could ever see myself using sendmail for, on this machine, is to send local mail only -- thus, I have no clue at all how to correctly configure ssmtp to not get this ridiculous error message.  Could someone possibly post a sample configuration to fix/disable the issue?

I also thought about installing postfix, but smtp seems to be in conflict with it, and I'm worried about breaking something (I'm pretty new to Gentoo).  So if someone couldn't help me with solution a, what steps would I have to take to install postfix without breaking other things?

----------

## lx

 *Jeff In Motion wrote:*   

> I also thought about installing postfix, but smtp seems to be in conflict with it, and I'm worried about breaking something (I'm pretty new to Gentoo).  So if someone couldn't help me with solution a, what steps would I have to take to install postfix without breaking other things?

 

Just unmerge ssmtp and install postfix, well that's what I've done, but if you don't have a need for postfix it seems like a very very very crude work around.

Maybe you can find out something using a dummy file /usr/sbin/sendmail containing something like

```
#!/bin/bash

echo ${*} > /tmp/sendmail.log

exit 0
```

ps. don't forget chmod +x /usr/bin/sendmail

Have you checked the var/log/everything or similar, normally errors are reported with the process causing them, well if you're lucky anyway.

Hope you'll fix it, seeing 2 people already have the same problem, so more to come,...

Cya lX.

----------

## really

i too have started to get the same error.

just after Telia (my isp) turned there port 25 off.

i dont actually care about the error message, all works fine  :Very Happy: 

but i do get this when iploging all traffic.

UDP: dgram to port 1035 from mail1.telia.com:53 (116 bytees) sometimes 113 and varies.

which is said to be the outgoing POP3 server.

i dont think thats a install problem sence i never saw that error for 4 mothns, but after they closed port 25 to stop the spammers or something it started coming up.

----------

## glober

 *lx wrote:*   

> 
> 
> Maybe you can find out something using a dummy file /usr/sbin/sendmail containing something like
> 
> ```
> ...

 

I should have checked before, but it in fact I do have /usr/sbin/sendmail executable on my system, and it is actually a link to /usr/sbin/ssmtp , which when I check, is in fact installed on my system.

My question now is, if I didn't emerge the "ssmtp" individually, will I break some dependancy if I do an unmerge of it, and will unmerging get rid of the problem.

Another observation I have, that after checking /var/log/everything , I do see that cron is causing this activity, and at an exact 15 min interval.  I didn't know there was a 15 minute cron.  Does anybody have an explanation?

here are the log entries that get repeated every 15 minutes:

Nov 13 22:45:00 [CRON] (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons ) 

Nov 13 22:45:00 [CRON] (root) CMD (root^Itest -x /usr/sbin/run-crons && /usr/sbin/run-crons ) 

Nov 13 22:45:00 [sSMTP mail] unable to connect to "mail" port 25. 

Nov 13 22:45:00 [sSMTP mail] can't open the smtp port (25) on mail.

Nov 13 22:45:00 [CRON] (root) MAIL (mailed 33 bytes of output but got status 0x0001 )

----------

## ronmon

So far so good, though I will give it a while before claiming success. Doing an 'emerge -C ssmtp' and 'emerge postfix' seems to have fixed it. /usr/sbin/sendmail is now a real executable instead of a link and no more nags in the log.

Nothing seems to have broken so it might be worth a shot.

----------

## darktux

Doing a 

```
fuser 25/tcp
```

wouldn't have been a bad idea.. I just read the first post, sorry if I'm off topic right now  :Smile: 

----------

## lx

 *glober wrote:*   

> Another observation I have, that after checking /var/log/everything , I do see that cron is causing this activity, and at an exact 15 min interval.  I didn't know there was a 15 minute cron.  Does anybody have an explanation?
> 
> here are the log entries that get repeated every 15 minutes:
> 
> Nov 13 22:45:00 [CRON] (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons ) 
> ...

 

the exact line is in /etc/crontab, and it's executed at an 15 min. interval. It's the hart of the cron.hourly etc, the hourly, daily etc are workarounds to simplify cron jobs. question is why it wants to mail, have you deleted /usr/sbin/run-crons or something, well I haven't added the file /etc/crontab cause I don't need it, it I want to do something hourly c.q. daily I can easily implement it using fcron, without the need of a script. I think you can run "crontab -e" (well at least with fcron) to see the users crontab,

Cya lX.

----------

## glober

 *lx wrote:*   

> 
> 
> the exact line is in /etc/crontab, and it's executed at an 15 min. interval. It's the hart of the cron.hourly etc, the hourly, daily etc are workarounds to simplify cron jobs. question is why it wants to mail, have you deleted /usr/sbin/run-crons or something, well I haven't added the file /etc/crontab cause I don't need it, it I want to do something hourly c.q. daily I can easily implement it using fcron, without the need of a script. I think you can run "crontab -e" (well at least with fcron) to see the users crontab,
> 
> Cya lX.

 

You are right, /etc/crontab does have what looks like what is being executed every 15 minutes.  Here is my crontab in full:

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly

# for vixie cron

# remember to give cron a sighup when updating this file

#

# $Header: /home/cvsroot/gentoo-x86/sys-apps/vcron/files/crontab,v 1.2 2002/04/27 21:46:45 bangert Exp $

#

#

*/15 * * * *	root	test -x /usr/sbin/run-crons && /usr/sbin/run-crons 

0 *  * * *	root	rm -f /var/spool/cron/lastrun/cron.hourly

0 0  * * *	root	rm -f /var/spool/cron/lastrun/cron.daily

0 0  * * 6	root	rm -f /var/spool/cron/lastrun/cron.weekly

0 0  1 * *	root	rm -f /var/spool/cron/lastrun/cron.monthly

Why its running SSMTP, Idon't know.  I do have the /usr/sbin/run-crons script on my system, and it also doesn't have any reference to SSMTP.  As far as crontab itself,  no I didn't add it myself,  and I am not really sure what the syntax means,  how I should edit, delete, or whatever.  Obviously " */15 " means it executes every 15 minutes.   BTW running "crontab -e" just shows me the contents of crontab.

----------

## lx

 *glober wrote:*   

> Why its running SSMTP, Idon't know.  I do have the /usr/sbin/run-crons script on my system, and it also doesn't have any reference to SSMTP.  As far as crontab itself,  no I didn't add it myself,  and I am not really sure what the syntax means,  how I should edit, delete, or whatever.  Obviously " */15 " means it executes every 15 minutes.   BTW running "crontab -e" just shows me the contents of crontab.

 

it default behaviour is to run /usr/bin/sendmail and send the output of the executed task or just a notificating that the task is executed.

Well except for vcron you have to manually install crontab using crontab /etc/crontab (it's in the install instruction of gentoo). This overrides the current crontab with the one in the file /etc/crontab. Running crontab -e, you can change the current crontab, so the one cron is actually using (well for dcron and fcron). 

Have you tried adding MAILTO="" (dcron, i think) ((or !MAIL=false (fcron))) as suggested earlier to the top of the crontab using crontab -e; maybe this needs a restart of cron, but I don't think so.

If this doesn't work you could make an empty script instead of the /usr/bin/sendmail link, but I don't know if this has consequences for other packages, 

 *Quote:*   

> ssmtp: A minimal mail-transfer agent which forwards mail to an SMTP server

 , I don't think you have it configured and therefor it gives an error.

Do you have crontabs in cron.h.... etc,  (/etc/cron.daily/whatis.... needs to be edited for it to work), else just remove the startup script from the boot level rc-update del dcron boot.

Hope you'll fix it,

Cya lX.

----------

## glober

 *lx wrote:*   

> 
> 
> Have you tried adding MAILTO="" (dcron, i think) ((or !MAIL=false (fcron))) as suggested earlier to the top of the crontab using crontab -e; maybe this needs a restart of cron, but I don't think so.
> 
> If this doesn't work you could make an empty script instead of the /usr/bin/sendmail link, but I don't know if this has consequences for other packages

 

I tried putting  MAILTO="" and !MAIL=false  into crontab with no results,  but I did decide to try and disable the /usr/sbin/sendmail  link,  which I did by renaming it to something else,  and presto,  the nagging message is gone.  Not that this gives me an automated mail system, but then on a home system I don't think I need one.  So far I haven't seen any bad after effects.

Thanks for your assistance,   glober.

----------

## mag

There are a few ways to fix the mail problem - either install a proper MTA or correct the configuration for SSMTP.

Edit /etc/ssmtp/sstmp.conf and put in a valid address for the mailhub variable. 

You could also always disable cron, but that's generally not recommended.

----------

## keratos68

MAILTO needs to be set to null string (i.e. export MAILTO="") in your global profile (i.e. /etc/profile.env)

The vixie-cron (VCRON) binaries are set to mail the person identified in the shell variable LOGNAME if MAILTO is not defined at all, wierd - but just set MAILTO to ""

----------

## Reformist

Running stderr to /dev/null in the /etc/crontab did the trick, because I had a job that was executing every minute (I meant it to be every hour, so I fixed that), and it was printing an error message because I wasn't online.

BTW, suggesting to fix /etc/ssmtp/sstmp.conf is not a good idea some of the time, because I had this message appearing every minute, which means if the mail forwarding option is actually set up correct, I'd be getting 60 emails an hour from cron =)

----------

## carrett

 *lx wrote:*   

>  *Jeff In Motion wrote:*   I also thought about installing postfix, but smtp seems to be in conflict with it, and I'm worried about breaking something (I'm pretty new to Gentoo).  So if someone couldn't help me with solution a, what steps would I have to take to install postfix without breaking other things? 
> 
> Just unmerge ssmtp and install postfix, well that's what I've done, but if you don't have a need for postfix it seems like a very very very crude work around.
> 
> Maybe you can find out something using a dummy file /usr/sbin/sendmail containing something like
> ...

 

the only trouble with the dummy is that if you have a cron job that sends out email every 15 mins. or something, /tmp/sendmail.log will get huge after a couple of weeks. i would do:

```
#!/bin/bash

echo ${*} > /dev/null

exit 0
```

unless of course you're using sendmail for anything...

----------

## BServiss

I had a problem with vixie-cron as it seemed to require sSMTP from the emerge --pretend. But after looking at the problems others have had with ssmtp due to improper setup(can't send mail:25), I looked at the ebuild for vixie-cron: 

RDEPEND="!virtual/cron

         sys-apps/cronbase

virtual/mta

         selinux? ( sys-libs/libselinux )"

Instead of a specific program, a generic application class is given and I would guess that ssmtp is first on the list. Also, since ssmtp is also virtual/mta it conflicts postfix.

I think vixie-cron should require postfix for regular handling of local mail. Should this be posted as a bug?

Brian

----------

