# ssmtp message size limit?

## grant123

My crontab isn't sending some messages and I think it's because they're too large.  Is there a size limit for messages sent by ssmtp?  If so, can I change it or should I switch to another mailer?

----------

## John R. Graham

There shouldn't be any unreasonably small limit. Just out of curiosity, how large are these messages?

- John

----------

## grant123

They're around 1.5MB.  It's the output from stuff like eix-test-obsolete and eix-sync.

----------

## John R. Graham

You know that two newlines in a row will terminate the mail message, right? If your input contains that, then the mail will be truncated. A simple filter can be written in sed, AWK or Perl that will fix that. Simplest one is

```
sed 's/^$/ /'
```

- John

----------

## grant123

I'm running identical commands on several machines in a crontab, and the only one that is sending the mail as it should is the machine that runs postfix instead of ssmtp.  It seems dangerous to run ssmtp with a size limit in case there is a massive amount of error output from an important (backup) command.

----------

## John R. Graham

So try the solution I proposed in my previous post. It may not be size limitations.

- John

----------

## grant123

OK, but the commands they're running are identical.  The output could vary a bit I suppose.  Can your script be integrated on the crontab line?

0  0  * * *     root    /etc/cron.d/script.sh

----------

## John R. Graham

That depends on what the script.sh contains. Care to share?

- John

----------

## grant123

Of course, it's not very interesting:

```
#!/bin/bash

SYSTEM=laptop

MAILTO=me@example.com

layman -S

eix-sync

eix-remote update

eclean -t 3m distfiles

eclean -t 3m packages

eix-test-obsolete 2>&1| mail -s "$SYSTEM: eix-test-obsolete" $MAILTO

revdep-rebuild -ip 2>&1| mail -s "$SYSTEM: revdep-rebuild -ip" $MAILTO

emerge -pvDuN world 2>&1| mail -s "$SYSTEM: emerge -pvDuN world" $MAILTO
```

----------

## John R. Graham

Sure. That would be

```
#!/bin/bash

SYSTEM=laptop

MAILTO=me@example.com

layman -S

eix-sync

eix-remote update

eclean -t 3m distfiles

eclean -t 3m packages

eix-test-obsolete 2>&1| sed 's/^$/ /' | mail -s "$SYSTEM: eix-test-obsolete" $MAILTO

revdep-rebuild -ip 2>&1| sed 's/^$/ /' | mail -s "$SYSTEM: revdep-rebuild -ip" $MAILTO

emerge -pvDuN world 2>&1| sed 's/^$/ /' | mail -s "$SYSTEM: emerge -pvDuN world" $MAILTO
```

  :Wink: 

- John

----------

## grant123

Thank you John!

----------

## grant123

I was about to put this together for testing but I realized I didn't explain it properly.  The mail command in my script is sending mail just fine.  The mail I'm not getting is the STDERR stuff I should be getting from crontab due to:

0  4  * * *     root    /etc/cron.d/update.sh > /dev/null

I'm running this on 5 machines and I only get mail from the machine which runs postfix instead of ssmtp.  Can you show me how to use sed in my script to make sure none of its lines are generating "end of message" characters, not just the lines running 'mail'?

----------

