Docker-mailserver: Build container on vagrant

Created on 6 Apr 2016  路  6Comments  路  Source: tomav/docker-mailserver

Hi,
I just built docker container on vagrant env, but I can't send emails from the container.

I sent mail like below from another container and got the error

> telnet mail 25 #from other docker container
Connected to mail.
220 mail.domain.com ESMTP Postfix (Ubuntu)  
> Mail from: [email protected]
250 2.1.0 Ok  
> RCPT to: [email protected]  
451 4.3.0 <[email protected]>: Temporary lookup failure

Mail server log is here

Apr  6 02:56:01 mail postfix/trivial-rewrite[598]: warning: non-existent:/etc/postfix/vhost is unavailable. open file /etc/postfix/vhost: No such file or directory
Apr  6 02:56:01 mail postfix/trivial-rewrite[598]: warning: non-existent:/etc/postfix/vhost: table lookup problem
Apr  6 02:56:01 mail postfix/trivial-rewrite[598]: warning: virtual_mailbox_domains lookup failure
Apr  6 02:56:01 mail postfix/smtpd[595]: NOQUEUE: reject: RCPT from hoge[**.**.**.**]: 451 4.3.0 <[email protected]>: Temporary lookup failure; from=<[email protected]> to=<[email protected]> proto=SMTP

I'm wondering above error is just because I don't have /etc/postfix/vhost or not?
If you have any idea, please let me know that.

Thank you for your help.

question

Most helpful comment

@kazu9su what's the content of your accounts.cf file, the one you have provided to the container ?
vhost gets populated while reading that file.

All 6 comments

@kazu9su what's the content of your accounts.cf file, the one you have provided to the container ?
vhost gets populated while reading that file.

@00angus Thank you for your reply.
I didn't prepare my accounts.cf.
So that means I have to preparing accounts.cf at /etc/postfix/ after deploying the container, right?

The best method I've found to startup this image is by providing the following setup and the command line that follows:

  • create a subdir, lets say mymail where will be stored the configs for the image, and enter that dir
  • you then will have to add a postfix subdir that will host the following files: accounts.cfand eventually virtual
  • optionally you can provide spamassassin rule file, additional configurations for postfix in a main.cf and so on; spamassassin rules should be located under mymail/spamassassin

Then you can use the following cmd line (that would be better to translate into a docker-compose.yml file).

 enter the mymail directory and from there:
 docker run -ti -h mail.domain.com -e "hostname=mail" -e "domainname=domain.com" -v "$(pwd)"/sp
 amassassin:/tmp/spamassassin -v "$(pwd)"/postfix:/tmp/postfix --name mail tvial/docker-mailserver

That way the image will find accounts.cfin /tmp/postfix/accounts.cf of the running container and will configure accounts accordingly.

HTH

And it's highly recommended to use docker-compose :-)
There are a lot of possible parameters (env, volumes, config...) and it's really more readable / maintainable using compose.

I put accounts.cf file in just like mymail/postfix dir and then I can set to address successfully.
Now, I have network problem but I think this is problem just about my environment.

Thanks a lot!

Great!

Was this page helpful?
0 / 5 - 0 ratings