diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3aa8108 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tgz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..238dfb4 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: smeserver-sendmail-wrapper +# $Id: Makefile,v 1.1 2021/11/07 02:45:48 jpp Exp $ +NAME := smeserver-sendmail-wrapper +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/README.md b/README.md index 17d3543..05877f4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ -# smeserver-sendmail-wrapper +# smeserver-sendmail-wrapper -SMEServer Koozali developed git repo for smeserver-sendmail-wrapper smecontribs \ No newline at end of file +SMEServer Koozali developed git repo for smeserver-sendmail-wrapper smecontribs + +## Wiki +
https://wiki.koozali.org/Sendmail-wrapper + +## Bugzilla +Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-sendmail-wrapper&product=SME%20Contribs&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED) + +## Description + +
*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.* +*Once it has been checked, then this comment will be deleted* +
diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..9b7fd51 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +contribs10 diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..ee81c56 --- /dev/null +++ b/createlinks @@ -0,0 +1,6 @@ +#!/usr/bin/perl -w +use esmith::Build::CreateLinks qw(:all); + + +# create smeserver-sendmail-wrapper-ipdate event as link to +safe_symlink("webapps-update", "root/etc/e-smith/events/smeserver-sendmail-wrapper-update") diff --git a/root/etc/e-smith/templates/etc/php.ini/80ModuleSettings02mailfunctionX b/root/etc/e-smith/templates/etc/php.ini/80ModuleSettings02mailfunctionX new file mode 100644 index 0000000..ba8bb53 --- /dev/null +++ b/root/etc/e-smith/templates/etc/php.ini/80ModuleSettings02mailfunctionX @@ -0,0 +1,11 @@ +{ + +return ";sendmail-wrapper.pl disabled to enable do: config setprop php sendmail enabled" if ($php{sendmail} || 'enabled') eq "disabled" ; +my $mailog = $phpcur->prop(MailLog) || $php{"MailLog"} || "disabled"; + +$OUT= "# smeserver-sendmail-wrapper contrib\n"; +$OUT= "mail.log= \"/var/log/sendmail/mail.log\"\n" if $mailog eq "disabled"; + +$OUT= "sendmail_path= \"/usr/bin/sendmail-wrapper.pl\"\n"; + +} diff --git a/root/etc/logrotate.d/sendmail-wrapper b/root/etc/logrotate.d/sendmail-wrapper new file mode 100644 index 0000000..760a019 --- /dev/null +++ b/root/etc/logrotate.d/sendmail-wrapper @@ -0,0 +1,10 @@ +/var/log/sendmail/*.log { + missingok + notifempty + compress + weekly + rotate 5 + create 0640 www www + su www www +} + diff --git a/root/usr/bin/sendmail-wrapper.pl b/root/usr/bin/sendmail-wrapper.pl new file mode 100755 index 0000000..723c465 --- /dev/null +++ b/root/usr/bin/sendmail-wrapper.pl @@ -0,0 +1,76 @@ +#!/usr/bin/perl +# initial script from https://github.com/xtremespb/sendmail-wrapper +# MIT License (MIT) Copyright (c) 2015 Michael Matveev + +use strict; +use warnings; +use Net::SMTP; +use Email::Address; +use Email::MessageID; +use Email::Date::Format qw(email_date); +use Net::Domain qw(hostname hostfqdn hostdomain domainname); + +my $user = getpwuid( $< ); +my $smtp_password = 'password'; +my $smtp_default_password = 'password'; +my $server = hostdomain () || hostfqdn () || domainname () || 'localhost'; +my $input = ''; +my $to_string = ''; +my $from_string = ''; +my $subject = ''; +my $messageID = ''; +my $Date = ''; + +# improve here to be sure it is in headers ! +# Email::Simple should do better ! +foreach my $line ( ) { + $input .= $line; + if ($line =~ /^To:/i) { + $to_string = $line;# + } + if ($line =~ /^From:/i) { + $from_string = $line; + } + if ($line =~ /^Subject:/i) { + $subject = $line; + } + if ($line =~ /^Message-Id:/i) { + $messageID = $line; + } + if ($line =~ /^Date:/i) { + $Date = $line; + } +} + +# add header if missing +my $mid= Email::MessageID->new->in_brackets; +$input = "Message-ID: $mid\r\n$input" unless $messageID ne ''; + +# add date if missing +my $dateheader = email_date(time); +$input = "Date: $dateheader\r\n$input" unless $Date ne ''; + +#check destination +my @addrs = Email::Address->parse($to_string); +if (0+@addrs eq 0) { + die "No recipients"; +} + +for (my$index=0;$index<=$#addrs;$index++){ + my $rec = $addrs[$index]; + $rec=$rec->address; + + my @fraddrs = Email::Address->parse($from_string); + my $frec = $user.'@'.$server; + $frec = $fraddrs[0]->address unless (0+@fraddrs eq 0) ; + + + my $smtp = Net::SMTP->new('127.0.0.1', Port => 25, Timeout => 10, Debug => 0); + die "Could not connect to qpsmtpd\n" unless $smtp; + $smtp->mail($frec); + $smtp->to($rec); + $smtp->data(); + $smtp->datasend($input); + $smtp->dataend(); + $smtp->quit; +} diff --git a/root/var/log/sendmail/.gitignore b/root/var/log/sendmail/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/smeserver-sendmail-wrapper.spec b/smeserver-sendmail-wrapper.spec new file mode 100644 index 0000000..d6bdcc0 --- /dev/null +++ b/smeserver-sendmail-wrapper.spec @@ -0,0 +1,77 @@ +# $Id: smeserver-sendmail-wrapper.spec,v 1.4 2024/02/29 02:19:25 jpp Exp $ +# Authority: unnilennium +# Name: Jean-Philippe Pialasse + +Summary: smeserver-sendmail-wrapper +%define name smeserver-sendmail-wrapper +%define version 0.1 +%define release 7 +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GPL +Group: Applications/System +Source: %{name}-%{version}.tar.xz +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildArch: noarch +BuildRequires: e-smith-devtools >= 1.13.1-03 +Requires: smeserver-release >= 9.0 + +%description +sendmail wrapper and templates to redirect php emails to qpsmtpd instead of qmail. +This is intended to introduce a little more verification before sending email thanks to the plugins of qpsmtpd instead of simply sending them blindly withthe qmail sendmail wrapper. + +%prep +%setup +mkdir -p root/var/log/sendmail + +rm -rf root/etc/e-smith/templates/opt + +%build +/usr/bin/perl createlinks + +%install +/bin/rm -rf $RPM_BUILD_ROOT +(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) +/bin/rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ +| grep -v var/log/sendmail > %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root,-) +%attr( 770 , www,www) /var/log/sendmail + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +touch /etc/hosts.deny_ssh + +%changelog +* Sat Sep 07 2024 cvs2git.sh aka Brian Read 0.1-7.sme +- Roll up patches and move to git repo [SME: 12338] + +* Sat Sep 07 2024 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Wed Feb 28 2024 Jean-Philippe Pialasse 0.1-6.sme +- fix missing su for logrotate [SME: 12495] + +* Sat Nov 06 2021 Jean-Philippe Pialasse 0.1-5.sme +- import to SME10 [SME: 11739] + +* Tue Apr 07 2020 Jean-Philipe Pialasse 0.1-4.sme +- add php73 support [SME: 10737] + fix typo for php72 + +* Wed Mar 07 2018 Jean-Philipe Pialasse 0.1-3.sme +- fix error on logrotate [SME: 10525] + +* Fri Mar 02 2018 Jean-Philipe Pialasse 0.1-2.sme +- fix log not accessible [SME: 10525] + moved to a www writable directory, also a logrotate has been added +- fix sendmail wrapper fails if not used by root + +* Fri Aug 18 2017 Jean-Philipe Pialasse 0.1-1.sme +- Initial version