# Adding a header to a mail created in CRON



## dmtr (Mar 10, 2016)

Good day!
There is an _interesting_ question.

After the script is run via CRON, which has the output (stdout), formed mail.
A mail is generated and sent via the MTA.

*Question: how in the headers to add their own headers?*

Interesting the Content-Type header.
Fix CRON source code is not considered.
I understand you need the wrapper to form the letters - the mediator.
May already have a solution in ports?


----------



## SirDice (Mar 10, 2016)

Have the script mail by itself instead of relying on a script's output being sent.


----------



## dmtr (Mar 10, 2016)

SirDice said:


> Have the script mail by itself instead of relying on a script's output being sent.


Therefore, I ask: write your own, or have ready in /usr/ports. If there is a ready, to show. If not ready, then tell how to write.


----------



## SirDice (Mar 10, 2016)

It depends on the script, Perl, Python, Ruby, etc. all have specific modules you can use to send email. This includes converting things to a MIME compatible format. For shell scripts you can use mail(1) combined with uuencode(1) and a bit of clever scripting.


----------



## Juha Nurmela (Mar 10, 2016)

Solutions like

```
DUMMY=\
Name: Value

* * * * * command # \
Name: Value
```
would have been amusing, but do not seem to be possible.

Juha


----------



## dmtr (Mar 11, 2016)

SirDice said:


> It depends on the script, Perl, Python, Ruby, etc. all have specific modules you can use to send email. This includes converting things to a MIME compatible format. For shell scripts you can use mail(1) combined with uuencode(1) and a bit of clever scripting.


It would be very ... difficult 
When dozens of scripts, this is not efficient.
It is better to have a single point of entry, which forms letters in a single rule.
While these rules are laid down in /usr/src/usr.sbin/cron/cron/do_command.c who wouldn't want to touch it.
Ideally the solution when a variable MAILCMD own script, where the preparation of the letter.


----------

