Results 1 to 3 of 3
I'm trying to preserve the format of a simple text message that gets sent via sendEmail. Here's an example of the message:
TOPIC ! ...LINE 1 of message TOPIC 2 ...
- 11-25-2011 #1Just Joined!
- Join Date
- Oct 2011
- Posts
- 10
text formatting
I'm trying to preserve the format of a simple text message that gets sent via sendEmail. Here's an example of the message:
TOPIC !...LINE 1 of messageTOPIC 2...LINE 2 of messageetc.
The beginnings of new lines, indentations, other formatting are lost when the text is sent. I may be asking too much of sendEmail but I wonder if someone can advise on this.
Thanks,
Lux
- 11-25-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Hey Lux,
First off, thanks for pointing out this cool utility. I've never heard of it before.
I got it to work, complete with tabs, indents, etc. in my message. Here's what I did to send the test email:
Perhaps on the client side, the email program is stripping the formatting?Code:#!/bin/bash sendEmail='/usr/local/bin/sendEmail' toEmail='me@myEmail.com' fromEmail=$toEmail subject='test' body=' This line starts with a tab Above is a blank line. This line is indented two spaces <-tab. ' smtpServer='my.smtp.server' smtpPort=25 smtpUser='mySmtpUser' smtpPass='mySmtpPass' printf "Sending email..." out=$($sendEmail -v -t $toEmail -f $fromEmail -u $subject -m "$body" -s $smtpServer:$smtpPort -o username=$smtpUser -o password=$smtpPass 2>&1) if [ $? -eq 0 ]; then echo OK else echo FAILED printf "$out\n" exit 1 fi exit 0
- 11-26-2011 #3Just Joined!
- Join Date
- Oct 2011
- Posts
- 10
Hi. Thanks for the reply. When I looked at your example I realized the problem was with the way I was inserting the message into the sendMail utility. Your example uses
-m "$body"
but I was complicating things by using
-m `cat $body`
which was evidently stripping out the formatting. Your way works. What a simple fix ! Thanks again.
lux11


Reply With Quote