mini_sendmail is a vary small application that will send a file via SMTP as an email.
- mini_sendmail's official website
- Download mini_sendmail - Local Backup (1.3.6 June 29, 2005) - git repo
- mini_sendmail Change Log
Downloading, Compiling, & Installing mini_sendmail
(The only prerequisite I know about is gcc & glibc-static, so mini_sendmail is pretty easy)
wget http://wiki.mattrude.com/images/5/52/Mini_sendmail-1.3.6.tar.gz tar -xzf Mini_sendmail-1.3.6.tar.gz cd mini_sendmail-1.3.6 make echo $? cp mini_sendmail /usr/local/bin gzip mini_sendmail.8 cp mini_sendmail.8.gz /usr/local/share/man/man8
Troubleshooting failed builds
If you do run into a build error similar to:
$ make gcc -O -c mini_sendmail.c gcc -O -s -static mini_sendmail.o -o mini_sendmail /usr/bin/ld: cannot find -lc collect2: ld returned 1 exit status make: *** [mini_sendmail] Error 1
Install the glibc-static packet. On Fedora, run:
yum install glibc-static
To send a message with mini_sendmail, run a command like this:
cat email.txt |mini_sendmail -firstname.lastname@example.org email@example.com
When email.txt looks something like this
subject: You can now put anything here for the email Subject And here you will put the body of your message.
From: firstname.lastname@example.org Subject: This is a test message To: email@example.com This is a test message.
mini_sendmail with php
Some linux distributions do not include sendmail in their base installation. Other folks may not want to run sendmail. Either way, if you want to use PHP's mail() function and you do not have a mail server installed locally, you need to find another way for mail() to sucessfully send email from a PHP script. mini_sendmail is a good choice for a basic, "I only need to send mail for testing on my development server" type of environment.
- Download and compile mini_sendmail (above).
- Create a symbolic link, so it looks like sendmail really exists:
ln -s /usr/local/sbin/mini_sendmail /usr/sbin/sendmail
- Edit your php.ini file to use appropriate options for sending mail: ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -firstname.lastname@example.org -smail.example.com
- Restart apache and that's it.
Notes: I found I needed to supply the From address in the sendmail path; otherwise the mail server I was using would not send the email. I also found that I compiled PHP without setting up mini_sendmail first, so PHP kept giving me the error about mail() not being a declared function. I chose that as a sign to upgrade to PHP 5.2.2. Install mini_sendmail first, then install PHP.
mini_sendmail Manual File
mini_sendmail(8) mini_sendmail(8) NAME mini_sendmail - accept email on behalf of real sendmail SYNOPSIS mini_sendmail [-f<name>] [-t] [-s<server>] [-p<port>] [-T<timeout>] [-v] address ... DESCRIPTION With no flags, mini_sendmail reads its standard input up to an end-of- file and sends a copy of the message found there to all of the addresses listed. The message is sent by connecting to a local SMTP server. This means mini_sendmail can be used to send email from inside a chroot(2) area. -f Sets the name of the "from" person (i.e. the sender of the mail). -t Read message for recipients. To:, Cc:, and Bcc: lines will be scanned for recipient addresses. The Bcc: line will be deleted before transmission. -s Specifies the SMTP server to use. Without this it uses local- host. -p Specifies the port to use. Without this it uses 25, the stan- dard SMTP port. -T Specifies timeout - defaults to one minute. -v Verbose mode - shows the conversation with the SMTP server. SEE ALSO sendmail(8) AUTHOR Copyright © 1999 by Jef Poskanzer <email@example.com>. All rights reserved. END 12 July 2001 mini_sendmail(8)