Sunday, October 27, 2013

Unable to get "sendmail" working on Raspberry Pi. Found that "sendEmail" works more easily



I wasn't able to get sendmail to work on Raspberry Pi.  I tried the following:
  • in /etc/hosts, add the following lines:
127.0.0.1localhost localhost. xxx (where xxx is the hostname of your Pi)
127.0.0.1 xxx.local. xxx (where xxx is the hostname of your Pi)
  • in /etc/mail/access add (or uncomment) the following line:
192.168.0   RELAY
  • in /etc/mail/local-host-names add the following line
xxx.localhost (where xxx is the hostname of your Pi)
  • when sending the mail use the following command:
/usr/sbin/sendmail -f you\@you.com youraddr\@gmail.com < /home/pi/mail.txt

However, I was never able to get it to work.  I always got timeout errors contacting the SMTP server.  Probably something simple to fix, but I never found it.

--------------------------------------------------------------------------------------

As an alternative, I tried 'sendEmail' which worked much better
  • Install the following:
sudo apt-get install sendEmail
sudo apt-get install libnet-ssleay-perl
sudo apt-get install libcrypt-ssleay-perl
sudo apt-get install libio-socket-ssl-perl libnet-ssleay-perl
sudo perl -MCPAN -e 'install Net::SSLeay'
sudo perl -MCPAN -e 'install IO::Socket::SSL'
sudo perl -MCPAN -e 'install Email::Send::SMTP::TLS'
  • Then had to edit the following file:
sudo vi /usr/local/share/perl/5.10.1/IO/Socket/SSL.pm
  • and modify line 1603 from this (remove the $):
   1603         m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?)$)}i
  • to this:
   1603         m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i
  • Then execute the following line:
sendEmail -f test@home.com -t <your_gmail account>@gmail.com -u "test subject" -m "test message" -s smtp.gmail.com -o tls=auto -xu <your gmail account> -xp <your gmail password>

Make sure that the smtp is specified using gmail.com and not google.com.  I made that mistake and it does not work

Check out my YouTube channel:  www.youtube.com/KedarWarriner


No comments:

Post a Comment