2

I'm trying to send a mail with a subject, a unique receiver, and few lines of text in the body. Almost everything is working as expected, except the body gets attached as a file instead of being in the mail's body.

Here is my code:

destinataire="[email protected]"
obj="** ALERTE BACKUP sur $host pour le dump DB de $db** "
body="Erreur lors du dump de la DB $db sur l'hote $host\n"
body="$body - Code erreur: $ret\n"
body="$body - Env: $prodfolder\n"
body="$body \n\nMail envoyé a $destinataire"
echo $body | mail -s "$obj" ${destinataire}

The content of $body gets transformed into a file, and attached to the mail. I don't understand what I am doing wrong, or if there is any additional configuration to do?

6
  • 1
    your example works fine with me... check stackoverflow.com/questions/18621899/… as well Commented Jan 24, 2014 at 15:12
  • 2
    @xlembouras Cheers, it was due to french character in the body. Commented Jan 24, 2014 at 15:19
  • 1
    @renard Maybe put this in a separate answer and tick it off as "correct" for others who run into similar issues... Commented Jan 24, 2014 at 15:20
  • @Thomas i'm doing it :) Commented Jan 24, 2014 at 15:21
  • maybe provide the link above for completeness Commented Jan 24, 2014 at 15:22

2 Answers 2

4

Thanks to xlembouras, and this post, the problem as been solved:

Language-specific characters such as é combined with default encoding set to UTF-8 (on the system the mail is being sent from) leads the body of the message to be transferred as attachment instead of raw text.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this instead:

mail -s "$obj" ${destinataire} <<EOF
Erreur lors du dump de la DB $db sur l'hote $host
 - Code erreur: $ret
 - Env: $prodfolder



Mail envoyé a $destinataire
EOF

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.