New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

How do I get b3 to send its own emails SOLVED

Got problems with your B2 or B3? Share and get helped!
Post Reply
Pressurized
Posts: 53
Joined: 11 Jun 2007, 17:12
Location: East of England

How do I get b3 to send its own emails SOLVED

Post by Pressurized »

Hi

Can someone please help me with a problem?

I'd like my b3 to be able to send emails to me when it encounters problems with cronjobs, etc. I've reserved a gmail address for it but now I'm stuck and a trawl of the forum has come up blank.

Thanks in anticipation
Last edited by Pressurized on 02 Nov 2013, 08:30, edited 1 time in total.
rog
Posts: 22
Joined: 22 Sep 2011, 00:19

Re: How do I get b3 to send its own emails

Post by rog »

At this point, do you know how you want to have the mail sent? I'm just trying to gauge if you're trying to script the process, or if you need help of a more basic nature.
Gordon
Posts: 1461
Joined: 10 Aug 2011, 03:18

Re: How do I get b3 to send its own emails

Post by Gordon »

The B3 already does send emails containing the output (and errors) from cron jobs. The trouble is that these emails get sent to root where it is quite difficult to read them. This forum does have some posts on this subject, related to these emails clogging up all the disk space of the root partition.

What you want to do is create an alias for root that will cause the system to deliver those emails to an alternate address. See `man aliases` for other options that this method offers.

Is there any reason why you want to send those emails to some external address? The B3 has a full blown email server, so why not use that one? On my B3 I simply created an alias that forwards all emails for root to admin, which allows me to read them using any standard email reader. You'll want one that allows having multiple email profiles though - I use Thunderbird myself.

A very powerful option for script jockeys is to use the pipe method of Postfix alias. This allows to tag and filter, so messages can be automatically placed in dedicated email folders rather than in separate email accounts, but you could also generate completely different automated responses to certain issues.
Pressurized
Posts: 53
Joined: 11 Jun 2007, 17:12
Location: East of England

Re: How do I get b3 to send its own emails

Post by Pressurized »

Guys, thanks for your replies.

rog
I'm reasonably confident with scripting but perhaps I do need more basic help. What I'm looking for is a command I can use in a script to send a message to my email address (gmail).

After my post I did find something that worked; ssmtp. This does the trick but, when I installed it, it caused a huge number of programs to be made redundant - apt suggested I run apt-get autoremove and this is the list:

Code: Select all

apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common avahi-daemon bc bind9-host bridge-utils bubba-album bubba-diskmanager bubba-horde bubba-igd bubba-manual bubba-networkmanager
  bubba-status ca-certificates compat-wireless consolekit cracklib-runtime crda cups cups-client cups-common cups-driver-gutenprint cups-ppdc davfs2 dbconfig-common dbus dc dimp1-base dmsetup dnsmasq
  dnsmasq-base dovecot-common dovecot-imapd duplicity epeg ethtool exiv2 expect fancontrol fetchmail filetransferdaemon fontconfig-config foo2zjs foomatic-db-compressed-ppds foomatic-filters forked-daapd
  fuse-utils gdisk geoip-database ghostscript ghostscript-cups gsfonts horde3-base hostapd hp-ppd hpijs hpijs-ppds hplip hplip-cups hplip-data ifplugd imp4-base incron iso-codes iw kronolith2-base
  libantlr3c-3.2-0 libapache2-mod-fastcgi libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libasound2 libasync-mergepoint-perl libavahi-client3 libavahi-common-data
  libavahi-common3 libavahi-core7 libavcodec52 libavformat52 libavl1 libavutil49 libbind9-60 libboost-date-time1.42.0 libboost-filesystem1.42.0 libboost-program-options1.42.0 libboost-python1.42.0
  libboost-regex1.42.0 libboost-system1.42.0 libboost-thread1.42.0 libbsd0 libbubba-info-perl libbubba-info-php libbubba-info0 libc-client2007e libck-connector0 libcommon-sense-perl libconfig-simple-perl
  libconfig-tiny-perl libconfuse0 libcps-perl libcrack2 libcrypt-passwdmd5-perl libcrypt-ssleay-perl libcups2 libcupscgi1 libcupsdriver1 libcupsimage2 libcupsmime1 libcupsppdc1 libcurl3-gnutls libdaemon0
  libdbus-1-3 libdbus-glib-1-2 libdevel-symdump-perl libdevmapper1.02.1 libdirac-encoder0 libdns69 libedit2 libeggdbus-1-0 libepeg0 libeutils1 libevent-core-1.4-2 libexif12 libexiv2-9 libexpect-perl
  libfaad2 libfile-basedir-perl libfile-copy-recursive-perl libfile-desktopentry-perl libfile-mimeinfo-perl libfile-slurp-perl libflac8 libfontconfig1 libfuse2 libgd2-xpm libgeoip1 libglib2.0-0
  libglib2.0-data libgphoto2-2 libgphoto2-port0 libgs8 libgsm1 libgssdp-1.0-2 libgupnp-1.0-3 libgutenprint2 libhal1 libheap-perl libhpmud0 libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl
  libice6 libicu44 libid3tag0 libieee1284-3 libijs-0.35 libimage-exiftool-perl libio-async-perl libio-pty-perl libio-stringy-perl libio-stty-perl libipc-run-perl libipc-run3-perl libipc-shareable-perl
  libisc62 libisccc60 libisccfg62 libjasper1 libjbig2dec0 libjpeg62 libjs-jquery libjs-jquery-ui libjs-prototype libjs-scriptaculous libjson-perl libjson-xs-perl liblcms1 liblist-moreutils-perl
  liblqr-1-0 liblwres60 libmagickcore3 libmailtools-perl libmcrypt4 libmxml1 libneon27-gnutls libnl1 libogg0 libonig2 libopenjpeg2 libopts25 liborc-0.4-0 libpam-ck-connector libpam-cracklib
  libpaper-utils libpaper1 libparse-debcontrol-perl libparted2 libpcre3 libperl5.10 libphp-codeigniter libplist1 libpod-coverage-perl libpolkit-backend-1-0 libpolkit-gobject-1-0 libpoppler5 libpq5
  libproc-daemon-perl libproc-processtable-perl libqdbm14 librsync1 libsane libsane-extras libsane-hpaio libschroedinger-1.0-0 libsensors4 libslp1 libsm6 libsnmp-base libsnmp15 libsocket-getaddrinfo-perl
  libsoup2.4-1 libspeex1 libsub-name-perl libswscale0 libt1-5 libtag1-vanilla libtag1c2a libtagc0 libtalloc2 libtest-pod-perl libtheora0 libtie-ixhash-perl libtiff4 libtimedate-perl libtorrent-rasterbar5
  libtry-tiny-perl libunistring0 liburi-perl libv4l-0 libvorbis0a libvorbisenc2 libwbclient0 libwww-perl libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxml-libxml-perl
  libxml-namespacesupport-perl libxml-parser-perl libxml-sax-perl libxml-simple-perl libxml2 libxpm4 libxslt1.1 libxt6 libyaml-0-2 lighttpd-spawnfcgi lm-sensors lsb-release lsof lvm2 mdadm minidlna mlock
  mnemo2-base ncftp netatalk ntp openprinting-ppds openssh-blacklist openssh-blacklist-extra openssh-client openssh-server openssl perlmagick php-date php-db php-file php-http-request php-http-request2
  php-http-webdav-server php-log php-mail php-mail-mime php-mail-mimedecode php-mdb2 php-mdb2-driver-mysql php-mdb2-schema php-net-imap php-net-socket php-net-url php-net-url2 php-pear php-soap php5-cgi
  php5-cli php5-common php5-gd php5-imap php5-intl php5-mcrypt php5-mysql php5-xcache policykit-1 poppler-utils proftpd-basic python python-apt python-apt-common python-argparse python-central
  python-configobj python-cups python-cupshelpers python-daemon python-dbus python-gnupg python-gnupginterface python-imaging python-lockfile python-minimal python-mysqldb python-netifaces python-openssl
  python-pam python-pexpect python-pkg-resources python-psutil python-pyexiv2 python-pyinotify python-serial python-support python-twisted-bin python-twisted-core python-twisted-web python-yaml
  python-zope.interface rsync samba samba-common samba-common-bin sane-utils sgml-base shared-mime-info splix sshfs sshpass ssl-cert system-config-printer-udev tcl8.5 tor tor-geoipdb torsocks turba2-base
  unzip update-inetd wamerican wireless-regdb xml-core xsltproc zip
Can you believe this - sshfs, python, rsync, samba all to be removed (I said no) - this cannot be right? So I'm thinking this is not an optimum solultion, or perhaps it's replacing a 'better' program already installed in the distribution.


Gordon
Ironically, after setting up ssmtp, I got an email today sent via ssmtp telling me it had failed to send an email to root@gmail.com when a cronjob failed!

To be honest, I probably should set up a bubba (I have a bubba|server, a bubba2 and a b3) as an email server. The PCs they serve in the house are Linux (Ubuntu) and Thunderbird is my email client. So this is now on my to-do list - is there a how-to on the forum?

But, in the meantime, I hope you can help me with, perhaps, a non-ssmtp soultion to my problem.

Cheers
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: How do I get b3 to send its own emails

Post by Ubi »

You decided to install and configure new software instead of just configuring already present software. I find this a little puzzling. If you change /etc/aliases to make mail for root go to any other (external) address, run the newaliases command and that is it. Nothing more is required and you are done in 30 seconds.

Anyway, you are thinking too difficult. All you need is one line.

Code: Select all

/usr/bin/somescript | mail -s "look at this" john@gmail.com
oh yeah, you pretty much borked your apt system by installing this ssmtp, so be careful when upgrading next time.

One last thing: Postfix (the mail software installed) lets you rewrite your sender address so it changes from root@localhost.com to something else. This helps you get around 'sender domain unknown' errors
Pressurized
Posts: 53
Joined: 11 Jun 2007, 17:12
Location: East of England

Re: How do I get b3 to send its own emails

Post by Pressurized »

Ubi, thanks for your email.

The decision to install ssmtp was based on ignorance of the command 'mail'! In summary, therefore: 'D'oh!'

Fortunately I'm in the early days of configuring the new b3 to take over my b2's functions so system borkage will be corrected by a reinstallation of the OS.

I'll investigate mail more carefully and, in the meantime, thanks very much to you and rog and Gordon for your help.

Cheers
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: How do I get b3 to send its own emails

Post by Ubi »

Well, this is how we all learned. The only way is the hard way :D :D

Don't worry too much about the upgrades though, mostly all are cosmetic, there are very few updates that actually fix a remote exploit vulnerability.

EDIT: of course, the exception just presented itself this week...
Last edited by Ubi on 02 Nov 2013, 10:19, edited 1 time in total.
Pressurized
Posts: 53
Joined: 11 Jun 2007, 17:12
Location: East of England

Re: How do I get b3 to send its own emails - SOLVED

Post by Pressurized »

Guys

After a bit more research, I found this Wiki which sorted out my problem:

http://wiki.excito.org/wiki/index.php/S ... sing_gmail

Great work excito!
Post Reply