Configure gmail with postfix to send notices from Koha

1. Installation of postfix mail server

Open a terminal and apply the following commands one by one,

sudo apt-get update
sudo apt-get install postfix


Select no configuration in the post installation screen.

2. Copy the configuration file.

sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf

3. Install following packages too

sudo apt-get install libsasl2-2
sudo apt-get install libsasl2-modules
sudo apt-get install ca-certificates

4. Open the following file and add few lines.

sudo leafpad /etc/postfix/main.cf

Add the following lines at the bottom of the file.

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

5. Create a new file to save the gmail password.
Either use an existing Gmail account or create a new one for the purpose send notices from Koha. Google turning off less secure app access to G Suite accounts. Use the following link to finish two-step verification for Google accounts. Create an app password for email clients (e.g. Exim, Postfix). https://support.google.com/accounts/answer/185833?hl=en

Open the following file and add Google app password of Gmail.

sudo leafpad /etc/postfix/sasl_passwd

Add the following line in the opened file.

[smtp.gmail.com]:587    urgmailid@gmail.com:yourpassword

Add your Gmail username and password.

6. Change the permission of the following file.

sudo chmod 400 /etc/postfix/sasl_passwd

7.  Translate the /etc/postfix/sasl_passwd to Postfix lookup tables.

sudo postmap /etc/postfix/sasl_passwd

8. Create the /etc/aliases.db

sudo postalias hash:/etc/aliases

9. Create the /etc/postfix/cacert.pem.

sudo cat /etc/ssl/certs/Equifax_Secure_CA.pem >> /etc/postfix/cacert.pem

For Ubuntu 18.04 LTS Users

sudo cat /etc/ssl/certs/thawte_Primary_Root_CA.pem >> /etc/postfix/cacert.pem

10.  Restart Postfix.

sudo /etc/init.d/postfix restart

11. Enable email service in Koha

Execute following command in a terminal

sudo koha-email-enable library

12. Enable less secure apps in Gmail account

Visit the link. 
13. Check the following settings in Koha to send email notices,

Koha > Administration > Patron categories > Overdue notice required > Yes
[Check for each patron category]


Koha Administration > Global System Preferences > Patrons > Enhancedmessagingpreferences > Allow

Set KohaTools > Overdue Notice/status triggers
 
Information courtesy
These instructions blindly borrowed from Eureka blog.
Vinod Kumar Mishra

14 comments:

  1. I tried this comments on my Zubuntu (Koha 3.10.01) it is working.

    Many thanks.

    ReplyDelete
  2. Dear Vimal,
    I installed postfix for koha emails. After every command on terminal screen, the system display "You Have New Message". Is it a problem?

    ReplyDelete
  3. I have install koha on Debain on my VPS so its possible to configure email with just only server IP address? cos i dont have DNS on my server

    ReplyDelete
    Replies
    1. Dear Friend,
      I have not tried this method with VPS. I think its possible to manage postfix and gmail from VPS.
      All the best,

      Delete
    2. Do this method above is for on Debian ?

      Delete
    3. You can try with Debian/Ubuntu

      Delete
  4. After every command on terminal screen, the system display "You Have New Message"

    ReplyDelete
    Replies
    1. I am not sure about the reason of message. May I know, Koha send email notices?

      Delete
  5. Sir I am Install Configure gmail with postfix but to not install the following error.

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package postfix is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package 'postfix' has no installation candidate
    root@mamcet-HP-dx2280-MT-GY563PA:/home/koha#

    Plz help me sir.

    ReplyDelete
  6. Dear Sir,

    I am an avid follower of your blog and I find it very useful because we are also using Koha. I have installed Koha on our local server, and it worked fine except the email notices. I have installed and configured the postfix and email notices triggers using the above procedures. However, Koha sent notices says the email status is 'sent' but when I checked my email I have received nothing from Koha... Can u help on this issue? Thank u very much in advance!

    ReplyDelete
  7. If you have a SMTP mail server somewhere else on your local network, and don't particularly want to set up postfix on your Koha server, an alternative to steps 1-10 (postfix) would be:

    (A) Copy /usr/share/perl5/Mail/Sendmail.pm to somewhere local (you can check which directories are in Perl's path with perl -V | sed -n '/INC:/,$p' ) for example:
    mkdir -p /etc/perl/Mail
    cp -p /usr/share/perl5/Mail/Sendmail.pm /etc/perl/Mail/Sendmail.pm

    (B) Edit your local Sendmail.pm (eg: /etc/perl/Mail/Sendmail.pm) and change the line
    'smtp' => [ qw( localhost ) ],
    to put your SMTP server name instead of "localhost", for example:
    'smtp' => [ qw( mail.example.com ) ],

    ReplyDelete
  8. Sir can you please help me in setting up cron jobs to send overdue notices and advance notices. Without having to do it manually .pl files.

    ReplyDelete
  9. Problems with dovecot are not easy to fix. See here for mark email threads

    ReplyDelete