📜 ⬆️ ⬇️

Sendmail stub for linux

Not so long ago, the task arose: to install a stub for sendmail, so that letters from PHP were not sent to false addresses (when testing), or there simply was no error, but folded neatly into a folder. Just like Denver does.
Further…

A search on the Internet has given nothing, except advice to read the manual to sendmail. But patience and perseverance have done their job. And, a few days later, on one of the forums I find an interesting shell script.
I had to fix it a little, for my needs. So, the script body:

#!/bin/sh
prefix="/var/mail/sendmail/new"
numPath="/var/mail/sendmail"

if [ ! -f $numPath/num ]; then
echo "0" > $numPath/num
fi
num=`cat $numPath/num`
num=$(($num + 1))
echo $num > $numPath/num

name="$prefix/letter_$num.txt"
while read line
do
echo $line >> $name
done
chmod 777 $name
/bin/true

Save the script to the / usr / bin folder under any name you like and make it executable (sudo chmod + x). I used fake_sendmail.sh.
')
Now all outgoing emails will be added to / var / mail / sendmail. It is also necessary to set write permissions for the folder. (chmod 777 -R / var / mail / sendmail).

Note:
To collect letters by mail (as described below), you need to create the following folder structure in this folder:
/ var / mail / sendmail /
- cur
- new
- tmp
And give rights to write.

PHP setup.
I have Kubunt, so all the ways are relative to her. So, we find the php.ini file in the / etc / php5 / apache2 folder and change the path to sendmail to:

sendmail_path = /usr/bin/fake_sendmail.sh.

All this can be finished. Next, read the suffering usability.

Binding a local folder to KMail.
Launch KMail and go to the options for creating a new account:
Settings -> Configure KMail -> Accounts -> Add.

Choose maildir mailbox, and in the settings of this account, in fact, the path to the folder with the letters (/ var / mail / sendmail).
It's all over. Now these letters can be picked up by mail and read in a digestible form.

Source: https://habr.com/ru/post/49665/


All Articles