progs:mailx
Содержание
msmtp
apt install msmtp-mta # узнать пути конфигов msmtp --version # mail bash: /usr/bin/mail: No such file or directory # Исправить: apt-get install mailutils
s-nail
Отправка почты из консоли.
echo "<html><pre>${body}</pre></html>" | s-nail -S v15-compat=yes -S mta="smtp://vasya:password123@example.com:25" -S smtp-use-starttls \ -S smtp-auth="login" -S from="vasya@example.com" -M text/html \ -s "Тема письма" \ petya@example.com kolya@example.com
Manual: https://manpages.ubuntu.com/manpages/bionic/man1/s-nail.1.html
Not URL percent encoded
Ошибка:
"stderr": "s-nail: Not URL percent encoded (use ```urlcodec enc'): *******\ns-nail: *mta*: invalid or unsupported value: smtp://vasya:*******@example.com:25\ns-nail: ... message not sent", "stderr_lines": ["s-nail: Not URL percent encoded (use```urlcodec enc'): *******", "s-nail:** ***mta*****: invalid or unsupported value: smtp://**vasya**:*******@example.com:25", "s-nail: ... message not sent"
Решение - кодировать пароль (url encode). В Ansible:
s-nail -S v15-compat=yes -S mta=smtp://{{ mail_username }}:{{ mail_password |urlencode }}@example.com:25 \
-S smtp-use-starttls -S smtp-auth=login -S from={{ mail_username }}@example.com -M text/html
mailx
Не умеет отправлять html-письма, нет возможности сменить Сontent-Type: на text/html.
Опция -a, которую рекомендовали в интернете, не работает, т. к. это вложение файла.
Трюк с добавлением Сontent-Type: text/html к теме письма тоже не работает.
progs/mailx.txt · Последнее изменение: — viacheslav
