Changes

Jump to navigation Jump to search
m
Line 100: Line 100:  
/etc/apache2/sites-available/webmail.conf
 
/etc/apache2/sites-available/webmail.conf
 
  <nowiki><VirtualHost *:80>
 
  <nowiki><VirtualHost *:80>
              ServerAdmin rafael@herrerosolis.com
+
              ServerAdmin rafael@herrerosolis.com
              Redirect permanent / https://webmail.herrerosolis.com/
+
              Redirect permanent / https://webmail.herrerosolis.com/
          #    DocumentRoot /var/www/rafael
+
          #    DocumentRoot /var/www/rafael
              ServerName webmail.herrerosolis.com
+
              ServerName webmail.herrerosolis.com
              ServerAlias webmail.herrerosolis.com
+
              ServerAlias webmail.herrerosolis.com
              ErrorLog /var/log/apache2/webmail/error.log
+
              ErrorLog /var/log/apache2/webmail/error.log
         
+
         
              # Posible values include: debug, info, notice, warn, error, crit.
+
              # Posible values include: debug, info, notice, warn, error, crit.
              # alert, emerg.
+
              # alert, emerg.
         
+
         
              CustomLog /var/log/apache2/webmail/access.log combined
+
              CustomLog /var/log/apache2/webmail/access.log combined
          </virtualHost>
+
          </virtualHost>
         
+
         
          <VirtualHost *:443>
+
          <VirtualHost *:443>
              ServerAdmin rafael@herrerosolis.com
+
              ServerAdmin rafael@herrerosolis.com
              DocumentRoot /var/lib/roundcube
+
              DocumentRoot /var/lib/roundcube
              ServerName webmail.herrerosolis.com
+
              ServerName webmail.herrerosolis.com
              ServerAlias webmail.herrerosolis.com
+
              ServerAlias webmail.herrerosolis.com
         
+
         
              ErrorLog /var/log/apache2/webmail/error.log
+
              ErrorLog /var/log/apache2/webmail/error.log
         
+
         
              # Posible values include: debug, info, notice, warn, error, crit.
+
              # Posible values include: debug, info, notice, warn, error, crit.
              # alert, emerg.
+
              # alert, emerg.
              CustomLog /var/log/apache2/webmail/access.log combined
+
              CustomLog /var/log/apache2/webmail/access.log combined
              SSLEngine on
+
              SSLEngine on
              SSLCertificateFile /etc/ssl/certs/herrerosolis.crt
+
              SSLCertificateFile /etc/ssl/certs/herrerosolis.crt
              SSLCertificateKeyFile /etc/ssl/private/herrerosolis.key
+
              SSLCertificateKeyFile /etc/ssl/private/herrerosolis.key
          </virtualHost>
+
          </virtualHost>
          </nowiki>
+
          </nowiki>
    
===OPTIONAL: Remove TinyMCE===
 
===OPTIONAL: Remove TinyMCE===
Line 136: Line 136:     
  <nowiki>Comment out these lines:
 
  <nowiki>Comment out these lines:
          #<Directory "/usr/share/tinymce/www/">
+
          #<Directory "/usr/share/tinymce/www/">
          #      Options Indexes MultiViews FollowSymLinks
+
          #      Options Indexes MultiViews FollowSymLinks
          #      AllowOverride None
+
          #      AllowOverride None
          #      Order allow,deny
+
          #      Order allow,deny
          #      allow from all
+
          #      allow from all
          #</Directory>
+
          #</Directory>
          </nowiki>
+
          </nowiki>
    
===Create Databases===
 
===Create Databases===
Line 152: Line 152:     
  <nowiki>CREATE TABLE mailboxes (
 
  <nowiki>CREATE TABLE mailboxes (
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
              domain_id INT(10) NOT NULL,
+
              domain_id INT(10) NOT NULL,
              local_part VARCHAR(250) NOT NULL,
+
              local_part VARCHAR(250) NOT NULL,
              password VARCHAR(100) NULL,
+
              password VARCHAR(100) NULL,
              description VARCHAR(250) NULL,
+
              description VARCHAR(250) NULL,
              active TINYINT(1) NOT NULL DEFAULT 0,
+
              active TINYINT(1) NOT NULL DEFAULT 0,
              created TIMESTAMP NOT NULL DEFAULT NOW(),
+
              created TIMESTAMP NOT NULL DEFAULT NOW(),
              modified TIMESTAMP NULL
+
              modified TIMESTAMP NULL
          );
+
          );
          CREATE TABLE aliases (
+
          CREATE TABLE aliases (
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
              domain_id INT(10) NOT NULL,
+
              domain_id INT(10) NOT NULL,
              local_part VARCHAR(250) NOT NULL,
+
              local_part VARCHAR(250) NOT NULL,
              goto VARCHAR(250) NOT NULL,
+
              goto VARCHAR(250) NOT NULL,
              description VARCHAR(250) NULL,
+
              description VARCHAR(250) NULL,
              active TINYINT(1) NOT NULL DEFAULT 0,
+
              active TINYINT(1) NOT NULL DEFAULT 0,
              created TIMESTAMP NOT NULL DEFAULT NOW(),
+
              created TIMESTAMP NOT NULL DEFAULT NOW(),
              modified TIMESTAMP NULL
+
              modified TIMESTAMP NULL
          );
+
          );
          CREATE TABLE vacations (
+
          CREATE TABLE vacations (
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
              mailbox_id INT(10) NOT NULL,
+
              mailbox_id INT(10) NOT NULL,
              subject VARCHAR(250) NOT NULL,
+
              subject VARCHAR(250) NOT NULL,
              body TEXT NOT NULL,
+
              body TEXT NOT NULL,
              description VARCHAR(250) NULL,
+
              description VARCHAR(250) NULL,
              active TINYINT(1) NOT NULL DEFAULT 0,
+
              active TINYINT(1) NOT NULL DEFAULT 0,
              created TIMESTAMP NOT NULL DEFAULT NOW(),
+
              created TIMESTAMP NOT NULL DEFAULT NOW(),
              modified TIMESTAMP NULL
+
              modified TIMESTAMP NULL
          );
+
          );
         
+
         
          CREATE TABLE domains (
+
          CREATE TABLE domains (
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+
              id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
              fqdn VARCHAR(250) NOT NULL,
+
              fqdn VARCHAR(250) NOT NULL,
              type ENUM('local','relay') NOT NULL DEFAULT 'local',
+
              type ENUM('local','relay') NOT NULL DEFAULT 'local',
              description VARCHAR(250) NULL,
+
              description VARCHAR(250) NULL,
              active TINYINT(1) NOT NULL DEFAULT 0,
+
              active TINYINT(1) NOT NULL DEFAULT 0,
              created TIMESTAMP NOT NULL DEFAULT NOW(),
+
              created TIMESTAMP NOT NULL DEFAULT NOW(),
              modified TIMESTAMP NULL
+
              modified TIMESTAMP NULL
          );
+
          );
          </nowiki>
+
          </nowiki>
    
===Create your first email account and domain===
 
===Create your first email account and domain===
Line 205: Line 205:  
===Create a database-account to access the database===
 
===Create a database-account to access the database===
 
  <nowiki>grant ALL on email_accounts.* to 'email'@'localhost' identified by 'password';
 
  <nowiki>grant ALL on email_accounts.* to 'email'@'localhost' identified by 'password';
          flush privileges;
+
          flush privileges;
          </nowiki>
+
          </nowiki>
 
http://bradthemad.org/tech/notes/exim_cheatsheet.php
 
http://bradthemad.org/tech/notes/exim_cheatsheet.php
   Line 217: Line 217:     
Creates the file: /etc/exim4/update-exim4.conf.conf<br />
 
Creates the file: /etc/exim4/update-exim4.conf.conf<br />
Should look like:
+
Should look like:<syntaxhighlight lang="text">
 +
# /etc/exim4/update-exim4.conf.conf
 +
#
 +
# Edit this file and /etc/mailname by hand and execute update-exim4.conf # yourself or use 'dpkg-reconfigure exim4-config'
 +
#
 +
# Please note that this is _not_ a dpkg-conffile and that automatic changes
 +
# to this file might happen. The code handling this will honor your local
 +
# changes, so this is usually fine, but will break local schemes that mess
 +
# around with multiple versions of the file.
 +
#
 +
# update-exim4.conf uses this file to determine variable values to generate
 +
# exim configuration macros for the configuration file.
 +
#
 +
# Most settings found in here do have corresponding questions in the
 +
# Debconf configuration, but not all of them.
 +
#
 +
# This is a Debian specific file
   −
<nowiki># /etc/exim4/update-exim4.conf.conf
+
dc_eximconfig_configtype='internet'
          #
+
dc_other_hostnames='[YOUR DOMAIN 1];[YOUR DOMAIN 2]'
          # Edit this file and /etc/mailname by hand and execute update-exim4.conf
+
dc_local_interfaces='127.0.0.1;[PUT YOUR SERVER's IP ADDRESS HERE]'
          # yourself or use 'dpkg-reconfigure exim4-config'
+
dc_readhost=''
          #
+
dc_relay_domains=''
          # Please note that this is _not_ a dpkg-conffile and that automatic changes
+
dc_minimaldns='false'
          # to this file might happen. The code handling this will honor your local
+
dc_relay_nets=''
          # changes, so this is usually fine, but will break local schemes that mess
+
dc_smarthost=''
          # around with multiple versions of the file.
+
CFILEMODE='644'
          #
+
dc_use_split_config='true'
          # update-exim4.conf uses this file to determine variable values to generate
+
dc_hide_mailname=''
          # exim configuration macros for the configuration file.
+
dc_mailname_in_oh='true'
          #
+
dc_localdelivery='maildir_home'
          # Most settings found in here do have corresponding questions in the
+
</syntaxhighlight>
          # Debconf configuration, but not all of them.
  −
          #
  −
          # This is a Debian specific file
  −
         
  −
          dc_eximconfig_configtype='internet'
  −
          dc_other_hostnames='[YOUR DOMAIN 1];[YOUR DOMAIN 2]'
  −
          dc_local_interfaces='127.0.0.1;[PUT YOUR SERVER's IP ADDRESS HERE]'
  −
          dc_readhost=''
  −
          dc_relay_domains=''
  −
          dc_minimaldns='false'
  −
          dc_relay_nets=''
  −
          dc_smarthost=''
  −
          CFILEMODE='644'
  −
          dc_use_split_config='true'
  −
          dc_hide_mailname=''
  −
          dc_mailname_in_oh='true'
  −
          dc_localdelivery='maildir_home'</nowiki>
      
====Macros====
 
====Macros====
Line 257: Line 256:  
ADD the following to /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs
 
ADD the following to /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs
 
  <nowiki># List of domains considered local for exim. Domains not listed here
 
  <nowiki># List of domains considered local for exim. Domains not listed here
          # need to be deliverable remotely.
+
          # need to be deliverable remotely.
          domainlist local_domains = MAIN_LOCAL_DOMAINS
+
          domainlist local_domains = MAIN_LOCAL_DOMAINS
         
+
         
          # MySQL because exim4 on Debian doesn't always add this:
+
          # MySQL because exim4 on Debian doesn't always add this:
         
+
         
          MYSQL_SERVER=127.0.0.1
+
          MYSQL_SERVER=127.0.0.1
          MYSQL_DB=email_accounts
+
          MYSQL_DB=email_accounts
          MYSQL_USER=email
+
          MYSQL_USER=email
          MYSQL_PASSWORD=password
+
          MYSQL_PASSWORD=password
          hide mysql_servers = MYSQL_SERVER/MYSQL_DB/MYSQL_USER/MYSQL_PASSWORD</nowiki>
+
          hide mysql_servers = MYSQL_SERVER/MYSQL_DB/MYSQL_USER/MYSQL_PASSWORD</nowiki>
    
====Routers====
 
====Routers====
Line 272: Line 271:     
  <nowiki>dovecot_user:
 
  <nowiki>dovecot_user:
                driver = accept
+
                driver = accept
                  condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) AS goto FROM domains,mailboxes WHERE \
+
                  condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) AS goto FROM domains,mailboxes WHERE \
                            mailboxes.local_part='${quote_mysql:$local_part}' AND \
+
                              mailboxes.local_part='${quote_mysql:$local_part}' AND \
                            mailboxes.active=1 AND \
+
                              mailboxes.active=1 AND \
                            mailboxes.domain_id=domains.id AND \
+
                              mailboxes.domain_id=domains.id AND \
                            domains.fqdn='${quote_mysql:$domain}' AND \
+
                              domains.fqdn='${quote_mysql:$domain}' AND \
                            domains.active=1}{yes}{no}}
+
                              domains.active=1}{yes}{no}}
              transport = dovecot_delivery</nowiki>
+
                transport = dovecot_delivery</nowiki>
    
Either DELETE this file, or comment-out all lines /etc/exim4/conf.d/router/400_exim4-config_system_aliases<br />
 
Either DELETE this file, or comment-out all lines /etc/exim4/conf.d/router/400_exim4-config_system_aliases<br />
Line 286: Line 285:     
  <nowiki>### router/401_exim4-config_mysql_aliases
 
  <nowiki>### router/401_exim4-config_mysql_aliases
          #################################
+
          #################################
         
+
         
          # ADAM: This router handles aliasing using the proprietary mysql setup
+
          # ADAM: This router handles aliasing using the proprietary mysql setup
          #
+
          #
          # c.f. http://alex.mamchenkov.net/2010/06/24/exim-dovecot-and-mysql/
+
          # c.f. http://alex.mamchenkov.net/2010/06/24/exim-dovecot-and-mysql/
          #
+
          #
         
+
         
          system_aliases:
+
          system_aliases:
              driver = redirect
+
                driver = redirect
              allow_fail  
+
                allow_fail  
              allow_defer
+
                allow_defer
              data = ${lookup mysql{SELECT aliases.goto AS goto FROM domains,aliases WHERE \
+
                data = ${lookup mysql{SELECT aliases.goto AS goto FROM domains,aliases WHERE \
                            (aliases.local_part='${quote_mysql:$local_part}' OR aliases.local_part='@') AND \
+
                              (aliases.local_part='${quote_mysql:$local_part}' OR aliases.local_part='@') AND \
                            aliases.active=1 AND \
+
                              aliases.active=1 AND \
                            aliases.domain_id=domains.id AND \
+
                              aliases.domain_id=domains.id AND \
                            domains.fqdn='${quote_mysql:$domain}' AND \
+
                              domains.fqdn='${quote_mysql:$domain}' AND \
                            domains.active=1}}
+
                              domains.active=1}}
          </nowiki>
+
          </nowiki>
    
====Transports====
 
====Transports====
Line 309: Line 308:     
  <nowiki>### transport/30_exim4-config_dovecot
 
  <nowiki>### transport/30_exim4-config_dovecot
          #################################
+
          #################################
         
+
         
          #
+
          #
         
+
         
          dovecot_delivery:
+
          dovecot_delivery:
              driver = appendfile
+
                driver = appendfile
              maildir_format = true
+
                maildir_format = true
              directory = /var/spool/mail/$domain/$local_part
+
                directory = /var/spool/mail/$domain/$local_part
              create_directory = true
+
                create_directory = true
              directory_mode = 0770
+
                directory_mode = 0770
              mode_fail_narrower = false
+
                mode_fail_narrower = false
              message_prefix =
+
                message_prefix =
              message_suffix =
+
                message_suffix =
              delivery_date_add
+
                delivery_date_add
              envelope_to_add
+
                envelope_to_add
              return_path_add
+
                return_path_add
              user = mail
+
                user = mail
              group = mail
+
                group = mail
              mode = 0660
+
                mode = 0660
          </nowiki>
+
          </nowiki>
    
====Auth====
 
====Auth====
Line 334: Line 333:     
  <nowiki>### AUTHENTICATIOR SECTION
 
  <nowiki>### AUTHENTICATIOR SECTION
         
+
         
          auth_plain:
+
          auth_plain:
              driver = plaintext
+
                driver = plaintext
              public_name = PLAIN
+
                public_name = PLAIN
              server_condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) FROM mailboxes,domains WHERE \
+
                server_condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) FROM mailboxes,domains WHERE \
                                mailboxes.local_part=SUBSTRING_INDEX('${quote_mysql:$auth2}','@',1) AND \
+
                                  mailboxes.local_part=SUBSTRING_INDEX('${quote_mysql:$auth2}','@',1) AND \
                                mailboxes.password=MD5('${quote_mysql:$auth3}') AND \
+
                                  mailboxes.password=MD5('${quote_mysql:$auth3}') AND \
                                mailboxes.active=1 AND \
+
                                  mailboxes.active=1 AND \
                                mailboxes.domain_id=domains.id AND \
+
                                  mailboxes.domain_id=domains.id AND \
                                domains.fqdn=SUBSTRING_INDEX('${quote_mysql:$auth2}','@',-1) AND \
+
                                  domains.fqdn=SUBSTRING_INDEX('${quote_mysql:$auth2}','@',-1) AND \
                                domains.active=1}{yes}{no}}
+
                                  domains.active=1}{yes}{no}}
              server_prompts = :
+
                server_prompts = :
              server_set_id = $auth2
+
                server_set_id = $auth2
         
+
         
          auth_login:
+
          auth_login:
              driver = plaintext
+
                driver = plaintext
              public_name = LOGIN
+
                public_name = LOGIN
              server_condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) FROM mailboxes,domains WHERE \
+
                server_condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) FROM mailboxes,domains WHERE \
                                mailboxes.local_part=SUBSTRING_INDEX('${quote_mysql:$auth1}','@',1) AND \
+
                                  mailboxes.local_part=SUBSTRING_INDEX('${quote_mysql:$auth1}','@',1) AND \
                                mailboxes.password=MD5('${quote_mysql:$auth2}') AND \
+
                                  mailboxes.password=MD5('${quote_mysql:$auth2}') AND \
                                mailboxes.active=1 AND \
+
                                  mailboxes.active=1 AND \
                                mailboxes.domain_id=domains.id AND \
+
                                  mailboxes.domain_id=domains.id AND \
                                domains.fqdn=SUBSTRING_INDEX('${quote_mysql:$auth1}','@',-1) AND \
+
                                  domains.fqdn=SUBSTRING_INDEX('${quote_mysql:$auth1}','@',-1) AND \
                                domains.active=1}{yes}{no}}
+
                                  domains.active=1}{yes}{no}}
              server_prompts = Username:: : Password::
+
                server_prompts = Username:: : Password::
              server_set_id = $auth1</nowiki>
+
                server_set_id = $auth1</nowiki>
      Line 417: Line 416:  
ADD to the file /etc/dovecot/dovecot.conf
 
ADD to the file /etc/dovecot/dovecot.conf
 
  <nowiki>protocols = imap
 
  <nowiki>protocols = imap
          listen = *, ::</nowiki>
+
          listen = *, ::</nowiki>
    
Add to the file /etc/dovecot/conf.d/10-mail.conf
 
Add to the file /etc/dovecot/conf.d/10-mail.conf
Line 427: Line 426:  
ADD to the file /etc/dovecot/dovecot-sql.conf.ext
 
ADD to the file /etc/dovecot/dovecot-sql.conf.ext
 
  <nowiki>driver = mysql
 
  <nowiki>driver = mysql
          connect = host=127.0.0.1 dbname=email_accounts user=email password=password
+
          connect = host=127.0.0.1 dbname=email_accounts user=email password=password
          default_pass_scheme = MD5
+
          default_pass_scheme = MD5
         
+
         
          password_query = SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) as `user`, mailboxes.password AS `password`,'/var/spool/mail/%d/%n' AS `userdb_home`, [YOUR UID] AS `userdb_uid`, [YOUR GID] AS `userdb_gid` FROM `mailboxes`, `domains` WHERE mailboxes.local_part = '%n' AND mailboxes.active = 1 AND mailboxes.domain_id = domains.id AND domains.fqdn = '%d' AND domains.active = 1
+
          password_query = SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) as `user`, mailboxes.password AS `password`,'/var/spool/mail/%d/%n' AS `userdb_home`, [YOUR UID] AS `userdb_uid`, [YOUR GID] AS `userdb_gid` FROM `mailboxes`, `domains` WHERE mailboxes.local_part = '%n' AND mailboxes.active = 1 AND mailboxes.domain_id = domains.id AND domains.fqdn = '%d' AND domains.active = 1
         
+
         
          user_query = SELECT '/var/spool/mail/%d/%n' AS `home`, [YOUR UID] AS `uid`, [YOUR GID] AS `gid`</nowiki>
+
          user_query = SELECT '/var/spool/mail/%d/%n' AS `home`, [YOUR UID] AS `uid`, [YOUR GID] AS `gid`</nowiki>
    
====SSL====
 
====SSL====
Line 438: Line 437:  
Edit: /etc/dovecot/conf.d/10-ssl.conf
 
Edit: /etc/dovecot/conf.d/10-ssl.conf
 
  <nowiki>ssl = required
 
  <nowiki>ssl = required
          # Preferred permissions: root:root 0444
+
          # Preferred permissions: root:root 0444
          ssl_cert = </etc/ssl/certs/dovecot.pem
+
          ssl_cert = </etc/ssl/certs/dovecot.pem
          # Preferred permissions: root:root 0400
+
          # Preferred permissions: root:root 0400
          ssl_key = </etc/ssl/private/dovecot.pem</nowiki>
+
          ssl_key = </etc/ssl/private/dovecot.pem</nowiki>
    
====Ports====
 
====Ports====
Line 460: Line 459:  
Add to /etc/roundcube/config.inc.php
 
Add to /etc/roundcube/config.inc.php
 
  <nowiki>$config['imap_conn_options'] = array(
 
  <nowiki>$config['imap_conn_options'] = array(
            'ssl'        => array(
+
            'ssl'        => array(
              'verify_peer'  => false,
+
                'verify_peer'  => false,
              'verify_peer_name'  => false,
+
                'verify_peer_name'  => false,
              'allow_self_signed' => true,
+
                'allow_self_signed' => true,
            ),
+
              ),
          );
+
            );
          </nowiki>
+
          </nowiki>
    
====Enable Password Plugin====
 
====Enable Password Plugin====
Line 496: Line 495:  
Then edit your local composer.json file and add the "vendor/plugin" names to the "require" section of the JSON structure. Don't forget to specify the version constraint:
 
Then edit your local composer.json file and add the "vendor/plugin" names to the "require" section of the JSON structure. Don't forget to specify the version constraint:
 
  <nowiki>"require" : {
 
  <nowiki>"require" : {
              ...,
+
              ...,
              "roundcube/rcsample": ">=0.2.0"
+
              "roundcube/rcsample": ">=0.2.0"
          }</nowiki>
+
          }</nowiki>
    
After every change to composer.json run
 
After every change to composer.json run
Line 505: Line 504:  
==Restart Everithing==  
 
==Restart Everithing==  
 
  <nowiki>/etc/init.d/apache2 restart
 
  <nowiki>/etc/init.d/apache2 restart
          /etc/init.d/exim4 restart
+
          /etc/init.d/exim4 restart
          /etc/init.d/dovecot restart</nowiki>
+
          /etc/init.d/dovecot restart</nowiki>
    
Exim may output a “paniclog”. If so, read it, fix it – and then manually delete the paniclog file, or else you’ll keep getting fake warnings every time you restart exim.
 
Exim may output a “paniclog”. If so, read it, fix it – and then manually delete the paniclog file, or else you’ll keep getting fake warnings every time you restart exim.

Navigation menu