# Mail Syslog [SOLVED]

## pmatos

Hi all,

What's the best way to get my syslogs mailed to my gmail account nightly?

Cheers,

Paulo MatosLast edited by pmatos on Sun Oct 18, 2009 9:38 pm; edited 1 time in total

----------

## Bones McCracker

logrotate

----------

## pmatos

 *tdurden wrote:*   

> logrotate

 

Thanks!  :Smile: 

----------

## Bones McCracker

Do you already have mail set up on your machine (i.e., and MTA, like ssmtp or sendmail or something)?

----------

## pmatos

 *tdurden wrote:*   

> Do you already have mail set up on your machine (i.e., and MTA, like ssmtp or sendmail or something)?

 

Not really... I guess I need to do that first, right?

----------

## Bones McCracker

Yes.  You'll need that.

If all you want to do is get system mail off the computer to somebody's regular mail account (say GMail), then all you need is a simple, send-only MTA (Mail Transfer Agent).  The Gentoo default for this is ssmtp.

The de-facto standard MTA in the Linux/Unix world is sendmail.  Therefore, most MTA programs (programs that can send/transfer mail) receive commands in sendmail format, and often function by a symlink named "sendmail" linked to their actual executable.

There are several different MTAs available in the Gentoo portage repository, including several similarly-named "light" ones like ssmtp, with varying functionality.  If you are interested, you can explore the portage category mail-mta.  You can probably just ignore that and just use ssmtp.

Here's a howto for setting up ssmtp with gmail.  There may be others available on the internet if you dig around.

http://www.destr0yr.com/article.php/Gmail_and_sSMTP

Keep in mind that with a "transfer-only" MTA, what's really happening here is that your computer is submitting your email message to the GMail server to be mailed out on behalf of of your GMail account.  In other words, you are not submitting it to be mailed TO your Gmail account; you are submitting it to be mailed BY your email account.

You might be able to submit it to be mailed BY and TO your email account (in other words, to be emailed to yourself), but some email servers block that as part of an anti-spam strategy.  If you try that, and it doesn't work, what you'll need to do is set up another GMail account for your administrative use (sort of a system mail account), and use that as the from information when you configure your ssmtp.  The mail would then be submitted to GMail to be mailed on behalf of your new sysadmin GMail account (i.e. "from" your sysadmin GMail account) "to" your regular GMail account (or to whomever it is addressed).

So that's probably what you want to do:

1. set up extra GMail account (your system mail account, for transferring mail off your machines).

2. emerge and configure ssmtp (or your chosen alternative MTA).

3. emerge and configure logrotate (which you can set up to mail certain logs at the end of the day).

One alternative you should be aware of is local mail.  Before smtp, pop, and imap came along, back when most UNIX systems were multi-user machines, facilities were built-in to allow sending messages back and forth between users on the same machine.  Using these facilities, you can have the system send mail to you on that system.  This is probably not useful to you unless the system in question is also your desktop.  However, if it is, the base package to set up this system-local mail functionality is called 'mail-base'.  A simple client for sending and receiving mail is 'mailx'.  An ssmtp alternative than can do local mail as well as transferring mail off the system is 'esmtp'.  And a useful MDA (mail delivery agent, moves mail messages from the system mail spool to user mailboxes, which you'd only need if you're doing local mail) is 'procmail'.

Again, what you probably want is ssmtp and logrotate.  Google for howto information on setting them up.  If you get stuck, start a new thread with your specific question.

Good luck.

----------

## pmatos

Thanks for the URL reference... was super-easy to work it out.

----------

