PHP mail() with MSMTP

PHP mail() made easy without a whole mail delivery system like sendmail or postfix.
Use msmtp http://msmtp.sourceforge.net/
Lightweight easy to install and configure.

Installation for LFS:

# wget http://sourceforge.net/projects/msmtp/files/msmtp/1.4.30/msmtp-1.4.30.tar.bz2
# tar -xvf msmtp-1.4.30.tar.bz2
# cd msmtp-1.4.30
# autoreconf -i
# ./configure --prefix=/usr
# make
# make install

Configuration for non authorized smtp access to your smtp provider:
ie. No username/password not encrypted.

Edit or create /usr/etc/msmtprc

And put the following in it.

# msmtp configuration file
# Set default values for all following accounts.
defaults
tls off
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
#logfile /var/log/maillog/msmtp.log

# The SMTP server of the provider.
account provider
host smtp.example.com
from youremail@example.com
auth off
#user 123456789
#passwordeval gpg -d ~/.msmtp.password.gpg

# Set a default account
account default : provider

You will have to change smtp.example.com with your smtp provider and change youremail@example.com with your own valid email address.

Next you will have to tell php to use msmtp.
Edit /etc/php.ini
Search for the line that starts with:
sendmail_path
uncomment it and/or change the line to this.

sendmail_path = "/usr/bin/msmtp -t"

Restart your httpd to activate the php changes.
Done !

Happy php mail()ing 🙂

RRDTool PHP plugin.

More on rrdtool

A continuation of Part 1 RRDTOOL with LIBART

Updated 2015 April 2. Using php 5.4.x and php 5.5.x and greater.

Now that the rrdtool version 1.2.30 with libart is working.
I want to use the php-rrdtool plugin that work with the 1.2.30 rrdtool version.
The only php rrd plugin that works is the plugin from the rrdtool website.
http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
The plugins for rrdtool found at php pecl only work for the newer versions of rrdtool.

Installing it:

# cd /usr/include/php/ext
# wget http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
# tar -xvf php_rrdtool.tar.gz
# cd rrd-tool
# phpize
# ./configure
# make
# make install

Last line of compile output is:
Installing shared extensions: /usr/lib/no-debug-non-zts-20131226/
(the date stamp varies depending on php version)

Changes to /etc/php.ini
Add or change the extensions-dir
extension_dir = “/usr/lib/no-debug-non-zts-20131226/”
Append below the extensions block
extension=rrdtool.so

Restart the httpd server so that php applies the changes.
Done !

However this only works for PHP versions 5.3.x and lower.
For PHP versions 5.4.x and greater the plugin fails to compile due to changes in php.
Some details about the php changes can be found here
Which has a link to a patch.
Good news and bad new. The patch didn’t quite work for me for reasons unknown. Maybe fedora uses a slight different/modified version. However I was able to fix the patch and it works !

** Update.
PHP version 5.5.x and greater breaks the plugin again.
I have updated the patch that fixes this. Use it when using php 5.4.x and greater.

Download my version of the patch for PHP 5.4.x or greater

Installing it with patch:

# cd /usr/include/php/ext
# wget http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
# wget http://www.shrike.tk/files/rrdtool-php55.patch
# tar -xvf php_rrdtool.tar.gz
# cd rrd-tool
# patch -Np1 -i ../rrdtool-php55.patch
# phpize
# ./configure
# make
# make install

Happy php graphing 🙂

RRDTOOL with LIBART

Issues with rrdtool 🙂
On Linux from Scratch.

Updated 2015 April 2. Using up to date package versions

rrdtool without cairo/pango
rrdtool with libart

Well rrdtool works great on all distro’s. I use(d) it my self on fedora and centos. No troubles…
But getting it to work on Linux From Scratch took some effort. The thing is that the latest versions of rrdtool are linked against cairo and pango. Which I don’t have installed nor do I want to. Cairo/Pango are X libs depending on even more X libs and X configurations. I’m running an X less server. No trace of X or GTK installed and I want to keep it that way.
So to get it to work I had to fall back to the latest version of rrdtool that didn’t depend on cairo/pango but depends on libart. Which is version 1.2.30 and is still available on the rrdtool website. The only dependencies are pkg-config, zlib, libpng, freetype, libart (optional Bzip2 but recommended).

Versions used:
zlib-1.2.8.tar.bz2 http://www.zlib.net/zlib-1.2.8.tar.xz

bzip2-1.0.6.tar.gz http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz

pkg-config-0.28.tar.gz http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz

libpng-1.6.16.tar.gz http://downloads.sourceforge.net/libpng/libpng-1.6.16.tar.xz

libpng-1.6.16-apng.patch.gz http://downloads.sourceforge.net/libpng-apng/libpng-1.6.16-apng.patch.gz

which-2.20.tar.gz http://ftp.gnu.org/gnu/which/which-2.20.tar.gz

icu4c-54_1-src.tgz http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.tgz

libffi-3.2.1.tar.gz ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz

Python-2.7.9.tar.xz https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz

freetype-2.5.5.tar.bz2 http://downloads.sourceforge.net/freetype/freetype-2.5.5.tar.bz2

harfbuzz-0.9.38.tar.bz2 http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.38.tar.bz2

libart_lgpl-2.3.21.tar.bz2 http://ftp.gnome.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.21.tar.bz2

rrdtool-1.2.30.tar.gz http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.30.tar.gz

Linux From Scratch users have already zlib, bzip2 and pkg-config installed and should skip those install steps.
Beyond Linux From Scratch users might have already libpng, which, icu, libffi, python, freetype, harfbuzz installed and should skip those install steps.
Or compile/install them again if earlier compiles did not include all dependencies listed above.

Installation documentation used.
rrdtool build instructions
LFS Book 7.7
BLFS Book 7.7

Package Installing:
ZLIB:
As per LFS 7.7 Book directive.

# ./configure --prefix=/usr
# make
# make install
# mv -v /usr/lib/libz.so.* /lib
# ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so

 
BZIP2
As per LFS 7.7 Book directive.

# sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
# make -f Makefile-libbz2_so
# make clean
# make
# make PREFIX=/usr install
# cp -v bzip2-shared /bin/bzip2
# cp -av libbz2.so* /lib
# ln -sv /lib/libbz2.so.1.0 /usr/lib/libbz2.so
# rm -v /usr/bin/{bunzip2,bzcat,bzip2}
# ln -sv bzip2 /bin/bunzip2
# ln -sv bzip2 /bin/bzcat

 
PKG-CONFIG
As per LFS 7.7 Book directive.

# ./configure --prefix=/usr --with-internal-glib --disable-host-tool --docdir=/usr/share/doc/pkg-config-0.28
# make
# make install

 
LIBPNG
As per BLFS 7.7 Book directive.

# gzip -cd ../libpng-1.6.16-apng.patch.gz | patch -p1
# ./configure --prefix=/usr --disable-static
# make
# make install
# mkdir -v /usr/share/doc/libpng-1.6.16
# cp -v README libpng-manual.txt /usr/share/doc/libpng-1.6.16

 
WHICH
As per BLFS 7.7 Book directive.

# ./configure --prefix=/usr
# make
# make install

 
ICU
As per BLFS 7.7 Book directive.

# cd source
# ./configure --prefix=/usr
# make
# make install

 
LIBFFI
As per BLFS 7.7 Book directive.

# sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' -i include/Makefile.in
# sed -e '/^includedir/ s/=.*$/=@includedir@/' -e 's/^Cflags: -I${includedir}/Cflags:/' -i libffi.pc.in
# ./configure --prefix=/usr --disable-static
# make
# make install

 
PYTHON
As per BLFS 7.7 Book directive.

# ./configure --prefix=/usr --enable-shared --with-system-expat --with-system-ffi --enable-unicode=ucs4
# make
# make install

 
FREETYPE
As per BLFS 7.7 Book directive.

# sed -i -r 's:.*(#.*SUBPIXEL.*) .*:\1:' include/freetype/config/ftoption.h
(the line above is optional see blfs book for details. patent stuff)
# ./configure --prefix=/usr --disable-static
# make
# make install

 
HARFBUZZ
As per BLFS 7.7 Book directive.

# ./configure --prefix=/usr --with-gobject
# make
# make install

 
FREETYPE (again to satisfy cyclic dependency with harfbuzz)
As per BLFS 7.7 Book directive.

# sed -i -r 's:.*(#.*SUBPIXEL.*) .*:\1:' include/freetype/config/ftoption.h
(the line above is optional see blfs book for details. patent stuff)
# ./configure --prefix=/usr --disable-static
# make
# make install

 
LIBART
(libart used to be in BLFS book but is no longer present in versions > 6.3)

# ./configure --prefix=/usr
# make
# make install

 
RRDTOOL
As per rrdtool build directive.
(–disable-tcl –disable-python are optional.)

# ./configure --prefix=/usr --disable-tcl
# make clean
# make
# make install

Done !
You now have rrdtool without cairo/pango.

Goto Part 2 RRDTool PHP plugin

Happy graphing 🙂