Exim: enabling CRAM-MD5 SMTP authorization (users in MySQL)

Practice



To enable CRAM-MD5 SMTP authorization we need to place a configuration block in the authenticators section:

...
begin authenticators
...

CRAM_MD5:
driver = cram_md5
public_name = CRAM-MD5
server_set_id = $auth1
server_secret = ${lookup mysql{SELECT password FROM users \
WHERE username='${local_part:${auth1}}' \
AND domain='${domain:${auth1}}' \
AND active='1'}{$value}fail}

This block assumes the use of MySQL to store user configurations. The users table in this case is the table where users are stored.

Let's decode the meaning of the database columns:
  • password: This field stores the user's plaintext password. If your password in the DB is encrypted (for example, with SHA1) - you should use a different approach;
  • username: This is the first part of the mailbox name - up to the @ symbol. For example, this is "webadmin" from the address "webadmin@mydomain.ru";
  • domain: This is the second part of the mailbox name - after the @ symbol. For example, this is "mydomain.ru" from the address "webadmin@mydomain.ru";
  • active: This is the field that contains "1" if the user is enabled (not blocked).

For example, take a case where the username is written as one part (username and domain are combined into a single field):

...
begin authenticators
...

CRAM_MD5:
driver = cram_md5
public_name = CRAM-MD5
server_set_id = $auth1
server_secret = ${lookup mysql{SELECT password FROM users \
WHERE username='${auth1}' \
AND active='1'}{$value}fail}
Applies to: Exim 4.7x

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Computer networks"

Terms: Computer networks