Sendmail stub for Linux

    Not so long ago, the task arose to install a stub for sendmail, so that letters from PHP would not be sent to false addresses (during testing) or there would simply not be an error, but they would fold neatly into a folder. Similar to how Denver does.
    Further ... A

    search on the Internet has yielded nothing but advice on reading the sendmail manual. But patience and perseverance did their job. And, a few days later, on one of the forums I find an interesting shell script.
    I had to correct it a little, for my needs. So, the body of the script: The script is saved in the / usr / bin folder under any name you like and made executable (sudo chmod + x). I used fake_sendmail.sh.

    #!/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



    Now all outgoing mail 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 a mailer (see below), you need to create the following folder structure in this folder:
    / var / mail / sendmail /
    - cur
    - new
    - tmp
    And give write permissions.

    PHP setup.
    I have Kubunta, 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 in it:

    sendmail_path = /usr/bin/fake_sendmail.sh.

    Everything, you can end it. Next read usability sufferers.

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

    We select maildir mailbox, and in the settings of this account, in fact, the path to the folder with letters (/ var / mail / sendmail).
    All done. Now these letters can be picked up by a mailer and read in a digestible form.

    Also popular now: