OpenWrt Forum Archive

Topic: [HOWTO] msmtp - Send email from OpenWrt using SMTP (here using GMail)

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all,

I've packaged msmtp, a sendmail compatabile SMTP forwarder that replaces the dated and unmaintained ssmtp package.

To set up msmtp to forward using GMail, install the msmtp package (with openssl support, see below on finding packages).

root@OpenWrt:~# opkg install http://etc.kupesoft.com/openwrt/msmtp_1.4.17-2_mipsel.ipk

Then, edit /etc/msmtprc to look something like this

account default

host smtp.gmail.com
port 587
auth on
user account@gmail.com
password password

auto_from off
from account@gmail.com

tls on
tls_starttls on
tls_certcheck off

logfile
syslog LOG_MAIL

Finally, you can send email like this,

root@OpenWrt:~# echo 'Hello, World!' | sendmail user@test.com

Or even in your scripts like this,

#!/bin/sh

EMAIL='To: user@test.com
Subject: EMERGENCY BROADCASTING SYSTEM

This is a test of the emergency broadcasting system.
Had there have been an actual emergency, you would have heard this message
followed by a long beep.'

echo "$EMAIL" | sendmail -t

Of course, msmtp can be configured many different ways. You can find more about how to configure msmtp by reading its manpage.

If you are connecting upstream to an SMTP server that doesn't use TLS authentication, go ahead and use the msmtp-nossl package, which is a bit smaller and doesn't require the rather large libopenssl dependency.

The package is now included in Openwrt, but you can grab the brcm-2.4 images it here...

     * msmtp (with openssl support) -- msmtp_1.4.17-3_mipsel.ipk
     * msmtp-nossl (without openssl support) --  msmtp-nossl_1.4.17-3_mipsel.ipk

Thanks,
Dave

Update: Bumped versions and the patch has been accepted in to OpenWrt. smile

(Last edited by kupesoft on 6 Feb 2009, 08:48)

Nice!

Maybe you can make it UCI aware.

Yanira wrote:

Maybe you can make it UCI aware.

I guess I could do that by auto-generating a config file from uci values, though I'm not entirely sure who would benefit from hacking a fairly low-order package like this.

kupesoft wrote:
Yanira wrote:

Maybe you can make it UCI aware.

I guess I could do that by auto-generating a config file from uci values, though I'm not entirely sure who would benefit from hacking a fairly low-order package like this.

You won't know until you do.

mazilo wrote:

You won't know until you do.

I'm unlikely to try this. tongue

But anyone is more than welcome to smile

Hello
I was installing using this tutorial, on version 8.09.02 - but came with errors:
* Only have 164 available blocks on filesystem /, pkg libopenssl needs 1270

Does anyone knows what does it mean?

After 'install' I cna't find binary named: sendmail

Thank you for support!
It is my first OpenWRT installation, but I already do love it smile


EDIT:
solved, by this:
echo 'option force_space' >> /etc/opkg.conf

(Last edited by huglester on 7 Feb 2010, 22:19)

The discussion might have continued from here.