# opensmtp refuses to start after update



## mariourk (Jan 4, 2013)

When I tried to restart opensmtp after an update, I get this error

```
Starting smtpd.
83926: fatal: ssl_init: cannot load certificate store: No such file or directory
/usr/local/etc/rc.d/smtpd: WARNING: failed to start smtpd
```

_pkg updating_ did mention there where some changes, that needed attention. But it wasn't clear about what those changes actually where.

```
20130102:
  AFFECTS: users of mail/opensmtpd
  AUTHOR: ashish@FreeBSD.org

  OpenSMTPD port has been updated to the latest portable snapshot. There 
  has been several changes to the configuration between the last version
  and this version, which requires configuration file need to be reviewed.
```

Here is my /usr/local/etc/mail/smtpd.conf

```
listen on 127.0.0.1
listen on ::1

map "aliases" { source db "/usr/local/etc/mail/aliases.db" }
map "secrets" { source db "/usr/local/etc/mail/secrets.db" }

accept for all relay via "mail.mydomain.com"
```

Any idea what is the cause of this error and how to fix it?


----------



## gilles (Jan 4, 2013)

Hi,

This was a bug in the previous snapshot, it has been fixed in the snapshot published yesterday. Hopefully the port maintainer will update soon ;-)

Gilles


----------



## mariourk (Jan 4, 2013)

Ah. Well, in that case I'll just wait.

Fortunately opensmtp is only used to mail some critical log reports. So, as long there are no drive crashes or anything, I'll be fine


----------



## k-nike (Jan 4, 2013)

gilles said:
			
		

> Hi,
> 
> This was a bug in the previous snapshot, it has been fixed in the snapshot published yesterday. Hopefully the port maintainer will update soon ;-)
> 
> Gilles



Gilees! Where did you get this information? I can not find.


----------



## gilles (Jan 5, 2013)

k-nike, I know because I cheated: I'm one of the developers and I tend to be the one releasing the snapshots ;-)


----------



## k-nike (Jan 5, 2013)

gilles said:
			
		

> k-nike, I know because I cheated: I'm one of the developers and I tend to be the one releasing the snapshots ;-)


Ok 

This information can be found somewhere on the official website? Is opensmtpd.org old?


----------



## k-nike (Jan 5, 2013)

P.S.
I was one of the first who uses this port.
See *Reported by* in Revision 296767 here.


----------



## gilles (Jan 5, 2013)

We're working *very* actively on it so we don't keep the website updated about changes in the snapshots (they are published every few days, sometimes very close because we spot a bug early), we just update the link to download them on the portable.html page.

However, we have a mailing list where we advertise and mention changes between snapshots. We're also present on IRC (#opensmtpd @ freenode) where we discuss devel and help users


----------



## mariourk (Jan 16, 2013)

I just updated opensmtp on another server. Same problem. :\

I figured this issue would be fixed by now


----------



## k-nike (Jan 20, 2013)

Finally, the port has been updated to opensmtpd-201301111154.
How to change the line is responsible for forwarding via gmail.com?

Old version:

```
accept for all relay via tls+auth://smtp.gmail.com:587 auth secrets as [email]name@domain.com[/email]
```
New version:

```
accept for all relay via smtp.gmail.com port 587 tls auth <secrets> as [email]name@domain.com[/email]
```
Syntax error!

smtpd.conf:

```
listen on lo0

expire 3d

table aliases db:/etc/mail/aliases.db
table secrets db:/etc/mail/secrets.db

accept for local alias <aliases> deliver to mbox

accept for all relay via smtp.gmail.com port 587 tls auth "secrets" as [email]name@domain.com[/email]
```


----------



## k-nike (Jan 21, 2013)

Updated to opensmtpd-201301191220, started with the following:

```
listen on lo0

expire 3d

table aliases db:/etc/mail/aliases.db
table secrets db:/etc/mail/secrets.db

accept for local alias <aliases> deliver to mbox

accept for any relay via tls://smtp.gmail.com:587 auth <secrets>
```

When sending any message, I get an error:

```
Jan 21 10:50:55 gate smtpd[89668]: smtp-in: New session 0000000201259d91 from host 0@localhost [local]
Jan 21 10:50:55 gate smtpd[89668]: smtp-in: Accepted message d35ef0ba on session 0000000201259d91: from=<root@domain.com>, size=202, nrcpts=1, proto=ESMTP
Jan 21 10:50:55 gate smtpd[89668]: smtp-in: Closing session 0000000201259d91
Jan 21 10:50:55 gate smtpd[89665]: smtp-out: Error on route [] <-> IPv6:2a00:1450:4010:c03::6c (la-in-x6c.1e100.net): Connection failed: No route to host
```

IPv6 is not set up on my PC!


----------



## mariourk (Jan 28, 2013)

I experience syntax errors too

```
Starting smtpd.
/usr/local/etc/mail/smtpd.conf:4: syntax error
/usr/local/etc/mail/smtpd.conf:7: syntax error
27188: warn: no rules, nothing to do
/usr/local/etc/rc.d/smtpd: WARNING: failed to start smtpd
```

smtpd.conf

```
listen on 127.0.0.1
listen on ::1

map "aliases" { source db "/usr/local/etc/mail/aliases.db" }
map "secrets" { source db "/usr/local/etc/mail/secrets.db" }

accept for all relay via "internal.mail.server"
```
How should I change this? Google wasn't much help :\


----------



## k-nike (Jan 29, 2013)

mariourk,

smtpd.conf:

```
listen on 127.0.0.1
listen on ::1

table aliases db:/usr/local/etc/mail/aliases.db
table secrets db:/usr/local/etc/mail/secrets.db

accept for any relay via tls+auth://[B]your_phrase[/B]@smtp.gmail.com:587 auth <secrets> #for example
```

secret:

```
your_phrase  gmail_username:gmail_password
```

But current port opensmtpd-201301191220 has an error. Gmail is not working.


----------



## mariourk (Jan 30, 2013)

After changing smtp.conf to this, it worked:

```
listen on 127.0.0.1
listen on ::1

accept for any relay via "internal.mail.server"
```
I removed the aliases and secrets reference, because they didn't exist anyway. And I want opensmtp to replay everything to another mailserver. So, those wheren't really needed. I also had to change _all_ to _any_ in the last line.


----------



## herot (Jan 31, 2013)

I too am unable to receive emails from my server to gmail after I updated last night.

*H*ere is /var/log/maillog:

```
Jan 31 08:09:31 hoth smtpd[4349]: smtp-out: Connected on session 00000036d3a53d44
Jan 31 08:09:31 hoth smtpd[4349]: smtp-out: Error on session 00000036d3a53d44: IO Error: Connection refused
Jan 31 08:09:31 hoth smtpd[4349]: smtp-out: Too many errors on host 173.194.70.26 (fa-in-f26.1e100.net): ignoring this MX
```

What do I need to do?


----------



## mariourk (Jan 31, 2013)

On second thought, I would like to use aliases. But I have no idea what the correct syntax is.

This is apparently the wrong syntax:

```
map "secrets" { source db "/usr/local/etc/mail/secrets.db" }
```

And this:

```
table aliases db:/usr/local/etc/mail/aliases.db
```
give the following error:

```
invalid backend configuration for table aliases
```

How can I fix this?


----------



## herot (Jan 31, 2013)

Here is my smtpd.conf:


```
listen on 127.0.0.1
listen on ::1

map "aliases" { source db "/usr/local/etc/mail/aliases.db" }
map "secrets" { source db "/usr/local/etc/mail/secrets.db" }


accept for local alias aliases deliver to mbox
accept for all relay via ssl+auth://smtp.googlemail.com:465 auth secrets as something@something
```

Here is what I get when I try to [cmd=]service smtpd start[/cmd]

```
Starting smtpd.
/usr/local/etc/mail/smtpd.conf:6: syntax error
/usr/local/etc/mail/smtpd.conf:10: invalid use of table "<dynamic:5>" as ALIAS parameter
/usr/local/etc/mail/smtpd.conf:11: syntax error
4511: warn: no rules, nothing to do
/usr/local/etc/rc.d/smtpd: WARNING: failed to start smtpd
```


----------



## k-nike (Feb 1, 2013)

mariourk said:
			
		

> How can I fix this?


You need to create a aliases.db file using opensmtpd:

```
cd /usr/local/etc/mail
/usr/local/libexec/opensmtpd/makemap aliases
```
Similarly for file secrets.db


----------



## k-nike (Feb 1, 2013)

herot said:
			
		

> Here is my smtpd.conf:
> 
> 
> ```
> ...



smtpd.conf:

```
listen on lo0

expire 3d

table aliases db:/usr/local/etc/mail/aliases.db
table secrets db:/usr/local/etc/mail/secrets.db

accept for local alias <aliases> deliver to mbox

accept for any relay via tls+auth://your_phrase@smtp.gmail.com:587 auth <secrets> as something@something
```

secrets:

```
your_phrase  gmail_username:gmail_password
```

It works for me in this configuration. opensmtpd-201301312105


----------



## herot (Feb 1, 2013)

k-nike said:
			
		

> smtpd.conf:
> 
> ```
> listen on lo0
> ...



What does "your_phrase" mean?


----------



## k-nike (Feb 1, 2013)

herot said:
			
		

> What does "your_phrase" mean?



It is a label.
File can have multiple entries for different servers.
For example:

```
label1  gmail_username:gmail_password
label2  hotmail_username:hotmail_password
...
```


----------



## herot (Feb 6, 2013)

I still can't get my mail working. Here are my files:

smtpd.conf

```
listen on 127.0.0.1
listen on ::1

table aliases db:/usr/local/etc/mail/aliases.db
table secrets db:/usr/local/etc/mail/secrets.db

accept for local alias <aliases> deliver to mbox

accept for any relay via tls+auth://creds@smtp.gmail.com:587 auth <secrets> as someone@somewhere
```

aliases

```
hoth# cat secrets
creds    someone@gmail.com:lalalalasomething
```

I am getting:

```
Feb  6 07:51:26 hoth smtpd[21432]: warn: pipe error with lka
Feb  6 07:51:26 hoth smtpd[21431]: warn: pipe error with control
```

What am I missing?


----------



## herot (Feb 6, 2013)

Is this a problem: ?

```
# $FreeBSD: release/9.0.0/etc/mail/mailer.conf 93858 2002-04-05 04:25:14Z gshapiro $
#
# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
#
###sendmail     /usr/libexec/sendmail/sendmail
###send-mail    /usr/libexec/sendmail/sendmail
###mailq                /usr/libexec/sendmail/sendmail
###newaliases   /usr/libexec/sendmail/sendmail
###hoststat     /usr/libexec/sendmail/sendmail
###purgestat    /usr/libexec/sendmail/sendmail
sendmail        /usr/local/sbin/smtpctl
send-mail       /usr/local/sbin/smtpctl
mailq           /usr/local/sbin/smtpctl
makemap         /usr/local/libexec/opensmtpd/makemap
newaliases      /usr/local/libexec/opensmtpd/makemap
```


----------



## k-nike (Feb 7, 2013)

herot,

1. /etc/mail/mailer.conf is right!
2. smtpd.conf is right!
3. secrets is right! but i use username without @gmail.com
4. you need create secrets.db. i use command:

```
cd /usr/local/etc/mail
/usr/local/libexec/opensmtpd/makemap secrets
```
5. similarly, you must create aliases.db

```
/usr/local/libexec/opensmtpd/makemap aliases
```
or delete this line:

```
table aliases db:/usr/local/etc/mail/aliases.db
```
6. restart opensmtpd:

```
/usr/local/etc/rc.d/smtpd restart
```


----------



## herot (Feb 7, 2013)

Knight didn't work.

results:

```
hoth# cat maillog
Feb  7 00:00:00 hoth newsyslog[25372]: logfile turned over
Feb  7 07:58:05 hoth smtpd[26538]: info: startup
Feb  7 07:58:05 hoth smtpd[26538]: warn: lost child: lookup exited abnormally
Feb  7 07:58:05 hoth smtpd[26541]: info: mail delivery agent exiting
Feb  7 07:58:05 hoth smtpd[26543]: info: mail transfer agent exiting
Feb  7 07:58:05 hoth smtpd[26545]: info: scheduler handler exiting
Feb  7 07:58:05 hoth smtpd[26539]: info: control process exiting
Feb  7 07:58:05 hoth smtpd[26542]: info: mail filter exiting
Feb  7 07:58:05 hoth smtpd[26544]: info: queue handler exiting
Feb  7 07:58:05 hoth smtpd[26546]: fatal: msgbuf_write: Socket is not connected
Feb  7 07:58:05 hoth smtpd[26538]: warn: parent terminating
```


----------



## herot (Feb 7, 2013)

I meant to call you k-nike. sorry


----------



## k-nike (Feb 7, 2013)

herot said:
			
		

> Knight didn't work.
> 
> ```
> Feb  7 07:58:05 hoth smtpd[26546]: fatal: msgbuf_write: Socket is not connected
> ```



k-nike! Not Knigth! 

I think you are running other e-mail program that listens to port 25. Likely sendmail. Do you disable it?

Need result:

```
sockstat -4 | grep :25
```

If you saw something (for example sendmail), you need disable it:

```
/etc/rc.d/sendmail stop
```
next

```
/usr/local/etc/rc.d/smtpd start
```
Next disable sendmail in /etc/rc.conf:

```
...
smtpd_enable="YES"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
```


----------



## herot (Feb 7, 2013)

sendmail was already disabled. sockstat revealed no sendmail.

/etc/rc.conf

```
# Disable Sendmail
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

# start smtpd instead of sendmail
smtpd_enable="YES"
```


----------



## k-nike (Feb 7, 2013)

1. Do you have root access?
2. Which version opensmtpd is used? 
3. Try to install the last version opensmtpd-201302051638 from ports.


----------



## k-nike (Feb 7, 2013)

4. Try use:

```
listen on lo0
```
instead

```
listen on 127.0.0.1
listen on ::1
```


----------



## herot (Feb 7, 2013)

I chmod(1)'ed everything in /usr/local/etc/mail to 777 and it worked. What are the correct permissions? I had them at 770 ; owner root.


----------



## herot (Feb 7, 2013)

herot said:
			
		

> I chmod(1)ed everything in /usr/local/etc/mail to 777 and it worked. What are the correct permissions? I had them at 770 ; owner root.



I chmod(1)ed secrets to 700 and it still worked. Is that sufficient?


----------



## k-nike (Feb 7, 2013)

i have:

```
/usr/local/etc/mail             root:wheel  755
/usr/local/etc/mail/smtpd.conf  root:wheel  644
/usr/local/etc/mail/secrets     root:_smtpd 640
/usr/local/etc/mail/secrets.db  root:_smtpd 640
/usr/local/etc/mail/aliases     root:wheel  640
/usr/local/etc/mail/aliases.db  root:wheel  640
```


----------



## k-nike (Feb 7, 2013)

sockstat -4 | grep smtp
_smtpd   smtpd      98783 4  tcp4   127.0.0.1:25          *:*


----------



## herot (Feb 7, 2013)

Alright, I'm good to go. Thanks for you help.


----------

