Setting up email on virtualbox vm

Does anyone have experience or can offer suggestions on setting up local email on the VirtualBox vm image? I’m running a recent download of the virtual image, and would like to setup ~30 dummy users for presentations and training (22 staff plus vendors and customers).

I had thought of creating local system users on the vm (e.g. tswift) and enter the local mail address in the ERPNext user profile (e.g. “tswift@erpnext”, since the vm hostname is “erpnext”). However, ERPNext will not accept the @erpnext email address (presumably because it’s missing a top-level-domain). Will this all work correctly if I change the hostname of the virtual machine to include a TLD? (e.g. “erpnext.local”, and use email addresses e.g. “tswift@erpnext.local”).

I’m not entirely familiar with ubuntu and the ERPNext virtual image, can anyone give guidance? Are there any tricks to changing the hostname if that’s needed?

I would likely setup SquirrelMail (or maybe Roundcube) with Apache for viewing mail (on an unused port).

Does this seem reasonable? Is anyone else doing anything similar? If so, how? Recommendations greatly appreciated! :slight_smile:

Thanks!

These notes highlight an example ‘localhost’ mail server setup, used to test ERPNext:

Download ERPNext VM (Ubuntu 14.04 LTS with Postfix mta already installed and running).

I used this howto Dovecot IMAP and Squirrelmail webmail client (Apache) http://www.krizna.com/ubuntu/setup-mail-server-ubuntu-14-04/

I followed krizna’s setup steps with these of note - these are not intended to be complete or comprehensive!

ERPNext requires users to have a ‘fully qualified domain name’ email id, for eg test1@erpnext.vm

'change ERPNext instance hostname to ‘fully qualified domain name’
sudo hostname erpnext.vm

frappe@banana:~/frappe-bench$ postconf -n | grep erpnext.vm
mydestination = erpnext.vm, localhost.localdomain, , localhost
myhostname = erpnext.vm

frappe@banana:~/frappe-bench$ grep mail /etc/hosts
127.0.0.1 localhost mail.erpnext.vm

'add username account ‘test1’ (the mail account share the same single password as this system user account that uses pam for authentication)
sudo adduser test1 frappe

'set password of user ‘test1’ to ‘test1’
sudo passwd test1

‘Configure Dovecot for PAM authentication’
frappe@banana:~/frappe-bench$ dovecot -n
# 2.2.9: /etc/dovecot/dovecot.conf
# OS: Linux 3.13.0-79-generic i686 Ubuntu 14.04.4 LTS
auth_debug = yes
auth_mechanisms = plain login
auth_username_format = %Ln
auth_verbose = yes
disable_plaintext_auth = no
passdb {
args = %n
driver = pam
}
protocols = imap
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
}
ssl = required
ssl_cert = </etc/dovecot/dovecot.pem
ssl_key = </etc/dovecot/private/dovecot.pem
userdb {
driver = passwd
}

This completes the setup - now run some test checks:

frappe@banana:~/frappe-bench$ sudo doveadm auth test test1
Password:
passdb: test1 auth succeeded
extra fields:
user=test1

View /var/log/auth.log
Dec 29 11:04:51 banana sudo: frappe : TTY=pts/0 ; PWD=/home/frappe/frappe-bench ; USER=root ; COMMAND=/usr/bin/doveadm auth test test1
Dec 29 11:04:51 banana sudo: pam_unix(sudo:session): session opened for user root by frappe(uid=0)
Dec 29 11:04:55 banana sudo: pam_unix(sudo:session): session closed for user root

frappe@erpnext:~/frappe-bench$ sudo telnet mail.erpnext.vm 143
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.

  • OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot (Ubuntu) ready.
    01 login test1 test1
    01 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE] Logged in

edit: The smtp login below requires a base64 encoding of your username and password; this explains how to generate that https://www.ndchost.com/wiki/mail/test-smtp-auth-telnet

frappe@erpnext:~/frappe-bench$ telnet mail.erpnext.vm 587
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 erpnext.vm ESMTP Postfix (Ubuntu)
ehlo erpnext.vm
250-erpnext.vm
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
dGVzdDE=
334 UGFzc3dvcmQ6
dGVzdDE=
235 2.7.0 Authentication successful

examples of /var/log/auth.log
Dec 29 12:31:13 banana sudo: frappe : TTY=pts/0 ; PWD=/home/frappe/frappe-bench ; USER=root ; COMMAND=/usr/bin/telnet mail.erpnext.vm 143
Dec 29 12:31:13 banana sudo: pam_unix(sudo:session): session opened for user root by frappe(uid=0)
Dec 29 12:32:12 banana sudo: pam_unix(sudo:session): session closed for user root
Dec 29 12:32:37 banana sudo: frappe : TTY=pts/0 ; PWD=/home/frappe/frappe-bench ; USER=root ; COMMAND=/usr/bin/less /var/log/auth.log
Dec 29 12:32:37 banana sudo: pam_unix(sudo:session): session opened for user root by frappe(uid=0)

Here are some screenshots for reference:

https://wiki2.dovecot.org/WhyDoesItNotWork
https://wiki.dovecot.org/Variables
https://wiki2.dovecot.org/Logging