m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/msmtp.rb
blob: 383be87ee8ac9488409c53c4cef4799d8e3dabee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def make_msmtp_config config
  accounts = config['accounts'].map do |account|
    <<~END.chomp
      # BEGIN profile generated by mmm
      account #{account['name']}
      host #{account['smtp']}
      port 587
      from #{account['email']}
      user #{account['email']}
      passwordeval "pass show #{account['pass_tag'] || account['name']}"
      # END profile generated by mmm
    END
  end

  accounts.join "\n\n"
end

def msmtprc_preamble
  <<~END
    defaults
    auth on
    tls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    logfile ~/.msmtp.log
  END
end