# Pipe text to ssmtp?

## d4mo

Isn't there any way to do this?  Whenever I try to do..... echo test | ssmtp my@domain.com.  The email goes through, but there's nothing in it.  Is the only way you can send email with ssmtp by typing it after you enter the command?

----------

## keyson

That should work.

You would get a mail without subject and test in the body.

To send a file you can

```

cat <file> | ssmtp -s "My text file" my@domain.com

```

where <file> is the name of the file you want to send.

And you get "My text file" in the subject.

For reference:

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

http://gentoo-wiki.com/HOWTO_Gmail_and_sSMTP#Troubleshooting

----------

## d4mo

It doesn't work.  -s doesn't put a subject in for some reason(but it's not listed in the man page either).  But if I try to pipe anything to ssmtp the email goes through, but it's completely blank.

----------

## keyson

Sorry forget the -s , it is if you use the mail program (mailx in portage)

That is why you did not find it in the man page.

But both 'echo test | ssmtp my@address.se' and 'cat <file> | ssmtp my@address.se' work for me.

But i'm only pass it to my mailserver and back.

----------

## d4mo

Ok heres the thing.  I still can't get echo to work.  But I can get cat filename.txt | test@domain.com to work.  But here's the weird thing:

Say I'm going to write and email that looks like this

```

Red

Brown

Black
```

It will leave out the word black.

If I do this:

```

Red Brown Black

```

The email will be blank.

If I do

```

Red 

Brown

Black

```

With the blank line at the beginning it will work fine.  Thats not a big deal, but it could make scripting annoying.  That would also explain why emails show up blank if I do an echo pipe.  Would there be any way to fix this.  Or to make a blank line with echo?

----------

## keyson

OK,

I can not get this behavior. But I made this test: 

```

echo -n test | ssmtp my@domain.se

```

Then it give a empty body. -n suppress trailing newline.

Check by

```
alias
```

That you don't have set echo to echo -n.

----------

## Suicidal

 *keyson wrote:*   

> OK,
> 
> I can not get this behavior. But I made this test: 
> 
> ```
> ...

 

cant you just do:

```
echo test | mail -s "Echoing Test" myuser@mydomain.com
```

----------

