Postfix for Gmail: Difference between revisions

imported from old wiki
 
Tie-ling (talk | contribs)
msmtp
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is how to setup Postfix to use Gmail as a relay host, so it can send email via Gmail, e.g. for output of cronjobs etc.
This is how to setup Postfix to use Gmail as a relay host, so it can send email via Gmail, e.g. for output of cronjobs etc.


== Setup sops-nix ==
== Option: use msmtp instead of postfix ==
Msmtp seems to be easier to configure, see [[ZFS#Mail_notifications_(ZFS_Event_Daemon)]]


Follow https://github.com/Mic92/sops-nix
== Secrets Configuration ==


Make sure you can create secrets in /run/secrets before continuing.
This page follows the configuration defined in <code>[https://github.com/Mic92/sops-nix sops-nix]</code>, but you can use any [[Comparison of secret managing schemes|secret managing scheme]].


== Add a "postfix/sasl_passwd" secret ==
== Add a "postfix/sasl_passwd" secret ==
Line 35: Line 36:
       # optional: Forward mails to root (e.g. from cron jobs, smartd)
       # optional: Forward mails to root (e.g. from cron jobs, smartd)
       # to me privately and to my work email:
       # to me privately and to my work email:
       virtual_alias_maps = "inline:{ {root=you@gmail.com, you@work.com} }";
       virtual_alias_maps = "inline:{ {root=you@work.example, you@home.example} }";
     };
     };
   };
   };
Line 53: Line 54:
     'echo "This is a test email." | mail -s "Test Email from NixOS to root" root'
     'echo "This is a test email." | mail -s "Test Email from NixOS to root" root'


== Source / Credit ==
== References ==


This post came out of this [https://discourse.nixos.org/t/porting-my-postfix-gmail-smtp-to-nixos/30286 discussion].
[https://discourse.nixos.org/t/porting-my-postfix-gmail-smtp-to-nixos/30286 Porting my postfix gmail smtp to nixos] on the NixOS Discourse.
 
 
[[Category:Mail Server]]
[[Category:Server]]