[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Mail for newbies (was Re: How does Cron send email?)

Hash: SHA1

On 02/21/07 18:53, Grok Mogger wrote:
> Miles Fidelman wrote:
>> Grok Mogger wrote:
>>>     I was hoping someone could help me understand how cron magically
>>> sends email.  My ultimate goal is to configure cron to send real
>>> Internet email so instead of just getting mail on my unix accounts on
>>> my linux box (which I read via the 'mail' command) I can get email at
>>> my gmail account.
>> Basic answer comes from the manpage for cron:
>>       When executing commands, any output is  mailed  to  the  owner 
>> of  the
>>       crontab (or to the user named in the MAILTO environment variable
>> in the
>>       crontab, if such exists).
>> so... simple answer is define MAILTO in your crontab
>> broader answer depends on what mail you want sent - you can always
>> include a sendmail command in whatever script you're running
>> Miles
> I have read the cron manpage.  I understand what cron mails and under
> what conditions it mails it, what I don't understand is HOW it mails
> it.  I know that cron just sends the output of whatever script it runs. 
> I don't understand how it mails that output.  I'd like to understand how
> it does that so that I can make it send email to a gmail account or a
> similar "real" Internet account.
> Are you telling me that if I set my MAILTO entry to something like
> 'Joe.Person@gmail.com', that's actually going to send legitimate
> Internet mail to Joe at his gmail account?  I find that hard to believe.

Every *ix box has a mail server (aka MTA, Mail Transfer Agent) on
it.  The default Debian MTA is exim4, but many use/like postfix.

That's how local mail is delivered, and how not-local mail is
delivered "up the chain".

AIUI, if configured as "Internet with smarthost", you tell your MTA
what your machine's name and domain are, and what the relay_host is
(that's your ISP's smtp server, which you typically enter into your
mail client).  Then, when "you" send an email, it gets piped to your
MTA which then looks at the address to determine whether it's a
local or remote address.  If local, it's sent to the correct local
mailbox.  If "To:" is remote, the mail stream gets relayed to what
ever machine is specified by the MTA config file's relay_host variable.

Next comes /etc/aliases.  Let's say some cron job sends an email to
root@localhost.  Your MTA then looks into /etc/aliases has an alias
definition for 'root'.  If so, it replaces root with the new
address.  If the new address is a non-local, it gets piped to the
system you define as the relay_host.

Version: GnuPG v1.4.6 (GNU/Linux)


Reply to: