%if 0%{!?mkrel:1}
%define mkrel(c) %{1}%{?dist}
%endif

Name:		msmtp
Version:	1.8.28
Release:	%mkrel 1
Summary:	An SMTP client
License:	GPLv3
Group:		System/Servers
Url:		https://marlam.de/msmtp/
Source0:	https://marlam.de/msmtp/releases/%{name}-%{version}.tar.xz
Source1:	msmtprc

BuildRequires:	pkgconfig(gnutls)
BuildRequires:  gcc, make
BuildRequires:	pkgconfig(libidn2)
BuildRequires:	pkgconfig(libsecret-1)
BuildRequires:	pkgconfig(libgcrypt)
BuildRequires:  pkgconfig(libgsasl) >= 2.2.1

Provides:	sendmail-command

%description
msmtp is an SMTP client that one can use with mail user agents that
that contain no mail transfer capability (e.g., Mutt).

Supported features:
- sendmail compatible interface (command line options and exit codes)
- SMTP AUTH methods PLAIN, LOGIN, CRAM-MD5 and EXTERNAL
  (and GSSAPI, DIGEST-MD5 and NTLM when compiled with GNU SASL support)
- TLS encrypted connections with the GnuTLS or OpenSSL libraries
  (including server certificate verification and the possibility to send
  a client certificate)
- LMTP support
- DSN (Delivery Status Notification) support
- RMQS (Remote Message Queue Starting) support (ETRN keyword)
- PIPELINING support for increased transmission speed
- IPv6 support
- support for multiple accounts

%prep
%setup -q

%build
%configure --with-libgsasl --with-tls=gnutls
%{__make}

%install
%make_install

mkdir -p %{buildroot}%{_sysconfdir}
cp %{SOURCE1} %{buildroot}%{_sysconfdir}/msmtprc
chmod 644 %{buildroot}%{_sysconfdir}/msmtprc

%find_lang %name

%post
update-alternatives \
	--install %{_sbindir}/sendmail sendmail-command %{_bindir}/msmtp 5 \
	--slave %{_prefix}/lib/sendmail sendmail-command-in_libdir %{_bindir}/msmtp

%preun
if [ $1 = 0 ]; then
        update-alternatives --remove sendmail-command %{_bindir}/msmtp
fi

%files -f %name.lang
%doc README THANKS NEWS COPYING AUTHORS doc/msmtprc-user.example
%doc doc/msmtprc-system.example scripts/msmtpqueue
%config(noreplace) %{_sysconfdir}/msmtprc
%{_bindir}/*
%{_mandir}/man1/*
%{_infodir}/*