# how to mail from console with charset in the header?



## sergling (Feb 10, 2017)

Hi,

I'm trying to mail localized text from asterisk to my mail,

`echo "тест" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "килирилица" mymail@gmail.com`

but mail  hasn't -a key. I'm used this key in linux-system. How I can do it in FreeBSD?

Thanks/


----------



## aragats (Feb 10, 2017)

I'm using sendmail(8) instead. Create a file /tmp/test.msg:
	
	



```
Content-Type: text/plain; charset=UTF-8
Subject: кириллица

тест 2
```
and run:
	
	



```
$ cat /tmp/test.msg | sendmail mymail@myserver.com
```


----------



## sergling (Feb 11, 2017)

Thanks, it's good alternative.


----------



## aragats (Feb 14, 2017)

There is a way to make the regular mail(1) working with extra headers. The following command adds a new line and the subsequent custom header:
	
	



```
echo работает | mail -s "`echo -e 'проверка\nContent-Type: text/plain; charset=UTF-8'`" mymail@myserver.com
```
However, it's not portable and works only in sh(1) or bash(1).
tcsh(1) uses a built-in `echo` which does not interpret "\n". In a shell script you can use a literal new line, and it works in all shells:
	
	



```
echo Работает! | mail -s "проверка кодировки
Content-Type: text/plain; charset=UTF-8" mymail@myserver.com
```


----------

