LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   uuencode question (https://www.linuxquestions.org/questions/linux-newbie-8/uuencode-question-780351/)

dennismonsewicz 01-06-2010 02:27 PM

uuencode question
 
I am working on a shell script that will send mail with attachments, but I am running into a small problem

Code:

uuencode file.txt attachment_file_name.txt | mail -a 'FROM:test@test.com' -s 'Subject Here' first.last@gmail.com
The problem I am having is, that when you try to run this code the email does not get sent cause the code breaks at the . [dot] in my email address. But it does not care if there is a . [dot] in the emaill address in the FROM address.

Any suggestions?

TB0ne 01-06-2010 02:34 PM

Quote:

Originally Posted by dennismonsewicz (Post 3816642)
I am working on a shell script that will send mail with attachments, but I am running into a small problem

Code:

uuencode file.txt attachment_file_name.txt | mail -a 'FROM:test@test.com' -s 'Subject Here' dennis.monsewicz@gmail.com
The problem I am having is, that when you try to run this code the email does not get sent cause the code breaks at the . [dot] in my email address. But it does not care if there is a . [dot] in the emaill address in the FROM address.

Any suggestions?

Try to put a backslash \ in front of the period.

dennismonsewicz 01-06-2010 02:54 PM

your suggestion worked thanks! The problem I am having now is that when I try to email my work address it doesn't work but if I email my personal email address it does...

colucix 01-06-2010 03:26 PM

Quote:

Originally Posted by dennismonsewicz (Post 3816670)
your suggestion worked thanks! The problem I am having now is that when I try to email my work address it doesn't work but if I email my personal email address it does...

Different mail services, different rules. Did you get a returning mail with some useful error message?

dennismonsewicz 01-06-2010 03:31 PM

Well I looked at the log files for mail and it is trying to send the mail to the username of the person logged into the shell who is running the uuencode script.

So if user is logged in and they run the script it tries to send the email to user@workaddy.com

I also modified some of the postfix settings to try to obey correctly

dennismonsewicz 01-06-2010 04:16 PM

yeah every time I try to send an email and go check the error logs I am seeing the 'unknown user' error...

So if I run my script with the recipient being user@useremail.com

The error will return 'user is unknown user'

colucix 01-06-2010 04:22 PM

Quote:

Originally Posted by dennismonsewicz (Post 3816711)
So if user is logged in and they run the script it tries to send the email to user@workaddy.com

That's weird, but it's difficult to find out the reason without viewing the actual script. Re-reading your previous post, I have some doubt on the correctness of the command line. First, uuencode should send its output to standard output in order to pipe it to the mail command (correct me if I'm wrong). Second, the option -a 'FROM:test@test.com' looks strange to me, but maybe it depends on the specific mail client used.

In the meanwhile, let me to suggest an alternative method which uses another "uu" application called uudeview. I'm used to send binary attachments in the following way and I've never had an issue:
Code:

recipient="pippo@null.domain"
subject="This is the subject"
sender="pluto@null.domain"

/usr/bin/uuenview -m "$recipient" -f "$sender" -s "$subject" -a attachment_file_name << EOF

This is the e-mail body.

Greetings,
Alex

EOF

Note that uudeview is the name of the package, whereas the encoding command is uuenview. Moreover uuenview takes care to pipe the mail to sendmail for you (without need to explicitly pipe it to the mail command). Just my :twocents:

A little hint: I hope the e-mail you wrote in post #1 is not real, otherwise better to change it into a fictional address! ;)


All times are GMT -5. The time now is 06:22 AM.