Forum

Full Version: How do I add email sending capabilities?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have installed flexget which can send notification emails. syslog has the following error;
Terminal
Jan 31 19:15:23 xbian anacron[1026]: Job `cron.daily' terminated (mailing output)
Jan 31 19:15:23 xbian anacron[1026]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
The folder, or any other containing 'mail', does not exist.

Please can someone give me NooB level instructions for adding this?[/quote]
First you need to install a basic MTA, like postfix or sendmail. I'd recommend postfix as it is way easier to setup if the default settings don't do what you want them to do. Sendmail config syntax is masochistic. (Postfix also comes with the binary /usr/sbin/sendmail, so that's compatible)

Then try and see if it works by default by sending a test mail with something like
Terminal
echo "test 1 2 3"|mailx -s "Test Email" receiver@domain.com

Most mail servers block connections from dynamic IPs, so if you have a dynamic IP, you will need to configure mail relaying through the ISPs mail relay gateway.
OK, I will give postfix a go. I found install instructions HERE. The instructions mention adding a domain. I have a couple of domains but they have their own mail servers and I do not want their DNS MX and A records confused by a duplicate entry. Do I have to enter these details or are they optional?

(1st Feb, 2014 08:21 PM)teekay Wrote: [ -> ]Most mail servers block connections from dynamic IPs, so if you have a dynamic IP, you will need to configure mail relaying through the ISPs mail relay gateway.
The emails will be sent via Gmail. I have copied a previously working config.yml with email setttings onto this install. I will let it run and see what happens.
Some good and bad results. The following are the notes I made during the install process.
Code:
    ALL the following need to be sudo commands (sudo -i first)
    apt-get ran a cript as configuration pages appeared
    Selecting Satellite system as that seems most apropriate (sending but not receiving)
    DOMAIN - no idea1. Just in case, I created xbixn.<mydomain>.com and used that. I hope that is OK!
    SMTP relay host - left blank
    apt-get continued

    During the apt-get run I noted the following information;
        Postfix is now set up with a default configuration.  If you need to make changes, edit /etc/postfix/main.cf (and others) as needed.  To view Postfix configuration values, see postconf(1).
        After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

    From the instructions
        Check the log mail.log, mail.err, mail.info, mail.warn to see if postfix runs
        cat /var/log/mail.xxxx - nothing returned

    The next instructions related to domains which I believe were dealt with above so I skipped to testing
    Testing
        telnet localhost 25 in SSH terminal returned "-bash: telnet: command not found"
        telnet xbian 25 in cmd window (wWin7) returned "Connecting To xbian...Could not open connection to the host, on port 25: Connect
failed"
    Now what? apt-get install telnet
    telnet, use modified example in instructions to generate a test email.
    Checked logs as above - ALL blank? Expected .log to have something.
    Check gmail for message - nothing
    Wait for flexget cron job to run. Log shows nothing new so no emails to send
I am now unsure if the setup is correct or not. The lack of anything in mail.log does not look good.
I was checking the syslog when I noticed that the mail.log and mail.info files had changed. The content is the same in both files but confusing.

Below is the telnet session input to create the message.
Terminal
mail from:<me>@gmail.com
rcpt to:<me>@gmail.com
data
To: <me>@gmail.com
From: <me>@gmail.com
Subject: Hey my first email
This is my first email on debian postfix after installing configuring it.
It was easy.

This is the mail.log
Code:
Feb  1 09:12:56 xbian postfix/sendmail[27602]: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
Feb  1 09:12:57 xbian postfix/postdrop[27605]: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
Feb  1 09:12:57 xbian postfix/cleanup[27608]: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
Feb  1 09:12:57 xbian postfix/trivial-rewrite[27616]: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
Feb  1 09:12:57 xbian postfix/cleanup[27608]: 67777ECD4: message-id=<20140201151257.67777ECD4@xbian>
Feb  1 09:12:57 xbian postfix/qmgr[14364]: 67777ECD4: from=<root@xbian.<mydomain>.com>, size=1743, nrcpt=1 (queue active)
Feb  1 09:12:57 xbian postfix/local[27619]: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
Feb  1 09:12:57 xbian postfix/local[27619]: 67777ECD4: to=<root@xbian.<mydomain>.com>, orig_to=<root>, relay=local, delay=0.53, delays=0.4/0.11/0/0.03, dsn=2.0.0, status=sent (delivered to mailbox)
Feb  1 09:12:57 xbian postfix/qmgr[14364]: 67777ECD4: removed
Feb  1 09:28:25 xbian postfix/master[14346]: terminating on signal 15
Why is it sending to/from <root@xbian.<mydomain>.com> when I thought I was sending to/from <me>@gmail.com?
@Gladfelder

postfix is full mail in the meaning designed to process millions of email / day. although it is possible to configure it just for outgoing mail, … makes no sense. either configure /etc/postfix/main.cf and postfix.cf

or install exim4-daemon-light or smail.

but for your purposes the best option is something like this http://www.logix.cz/michal/devel/smtp-cli/
(3rd Feb, 2014 09:34 AM)mk01 Wrote: [ -> ]@Gladfelder

postfix is full mail in the meaning designed to process millions of email / day. although it is possible to configure it just for outgoing mail, … makes no sense. either configure /etc/postfix/main.cf and postfix.cf

or install exim4-daemon-light or smail.

but for your purposes the best option is something like this http://www.logix.cz/michal/devel/smtp-cli/
Thanks for those ideas.

I believe I have actualy got it working. I followed these comrehensive instructions to the letter Get cron/alert mails to external address using Postfix+Gmail. Before doing that I did apt-get --purge remove postfix to ensure I was starting from scratch. Curiously, the testing at the end did not work but I am now getting 'Anacron job 'cron.weekly' on xbian' (and daily) emails so it appears to be working.
(3rd Feb, 2014 11:35 PM)Gladfelder Wrote: [ -> ]I am now getting 'Anacron job 'cron.weekly' on xbian' (and daily) emails so it appears to be working.

I have configured sendmail + ssmtp with my gmail address because I have a script that sends a link once a week to a bunch of friends.
however I'm also receiving those weird cron.daily/cron.weekly messages because root@xbian is not a valid email address.
I have already tried adding MAILTO="" to cron file (by running crontab -e) but this doesn't work for daily and weekly system crontab obviously.
Reference URL's