Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

mailing with attachment outside domain problem

renarios
Trusted Contributor

mailing with attachment outside domain problem

Hi,

I have two functions in a shell script which mails an attachment. The first one gives a notification to me if the script was executed successfully (displayed below)
The second function mails a data file to several people.
The script is executed from a HP-UX 11.11 box

function f_success_mail
{
subject=" Script ${SCRIPTFILE} executed successfully"

printf "\a \n ${subject} \n \n" >> ${LOGFILE}

logalias=verslag.log
# echo "Convert file to DOS mode..."
unix2dos ${LOGFILE} ${LOGFILE} 2>/dev/null

# Send the E-mail message...
/usr/bin/mailx -m -s "${subject}" ${SUCCESS_ADDRESS} <<-EOF

Hi,

Script ${SCRIPTFILE} runned successfully.

See attachment: ${logalias}
~< ! uuencode ${LOGFILE} ${logalias}


This email message was created automatically by UNIX

~.
EOF
}

The problem is: The second function does will only be delivered to people inside our domain, but it will not be delivered outside our domain.

The mail.log on HP-UX tells me: “Message accepted for delivery”
In the maillog of the smart relay host (a linux can) the following line occurs:
Apr 8 08:45:34 hrn20 sendmail[14100]: j386jBl9014079: to=, delay=00:00:23, xdelay=00:00:06, mailer=esmtp, pri=175848, relay=mx1.bit.nl. [xxx.xxx.xx.xxx], dsn=5.6.0, stat=Data format error.
I think that the oracle@srv-h.foo.nl

If I use the -r option (return address) the mail will be sent without the attachment, because the -r option disables all tilde commands. If I send the mail without the –r option the mail probably gets rejected by the mail relay server.

Does anyone have a good advice (I prefer a solution though)?

Rena
Nothing is more successfull as failure
8 REPLIES
Peter Godron
Honored Contributor
renarios
Trusted Contributor

Re: mailing with attachment outside domain problem

Hi Peter, thanks for your quick reply!

I already found those threads in another forum, but since i am DBA and do not have access as root of the relay host, I first hope to find the solution in my syntax instead of annoying our system administrator with sendmail configuration changes, because he is very busy with another project and I yet don't want to die.

Cheers,

Renarios
Nothing is more successfull as failure
RAC_1
Honored Contributor

Re: mailing with attachment outside domain problem

The one problem that I noticed with with your syntax is as follows. your here doc start with -EOF and ends with EOF. Shouldn't it start and end with same word?? EOF and EOF.

Other than this there seems to be no error with syntax.
There is no substitute to HARDWORK
renarios
Trusted Contributor

Re: mailing with attachment outside domain problem

Hi RAC,

The -EOF escape leading tabs in the second EOF. That's not the problem, but only for nicely identing scripts. Some people love it, some hate it like their mother in law...

The syntax is OK, but let me trie to explain. When you mail like:

mailx -r ${reply_adress} -m -s "${subject}" ${address} <<-EOF
Hey dude,

blah blah

Here is the attachment: ${alias}
~< ! uuencode ${file} ${alias}

Cheers man!

~.
EOF

The tildes [~] are disabled (see man mailx) and no attachment will be sent.

When you mail without the -r option the mail somewhere dissapeares.
What I like to know is: Can I replace the tilde commands with something else? i.e.
hubbabubba ~< ! uuencode ${file} ${alias}
...
hubbabubba.

Thanks,

Renarios
Nothing is more successfull as failure
Dave La Mar
Honored Contributor

Re: mailing with attachment outside domain problem

Rena -
Didn't look at the other url threads, but you should get your SA to put an entry in your send mail configuration file for the mail server in your environment.

This was the edit our shop required.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
RAC_1
Honored Contributor

Re: mailing with attachment outside domain problem

What does the local mail.log file say??
There is no substitute to HARDWORK
renarios
Trusted Contributor

Re: mailing with attachment outside domain problem

Hi all,

Excuse me for the late reply, I had a day off yesterday. I have found the solution. To get rid of the tilde commands, I used the following command:

mailx -r ${SENDER} -m -s ${subject} ${RECEIVER} << EOF
$(ux2dos ${DATFILE} | uuencode ${filealias})
Hey dude,

blah blah

Here is the attachment: ${alias}
EOF

Thanks for all the replies.
Cheers,

Renarios
Nothing is more successfull as failure
renarios
Trusted Contributor

Re: mailing with attachment outside domain problem

I lost the URL, but this is where I found the solution in:

Mail No attachment, body only -

mailx -m -s "Some Subject" somone@somewhere.com < file_for_email_body

Mail with attachement, no body -

ux2dos /path_to/some_file | uuencode some_file.txt | mailx -m -s "MAIL FROM Someone" someone@somewhere.com

Mail with attachment and body -

ux2dos /path_to/some_file | uuencode some_file.txt | mailx -m -s "MAIL FROM Someone" someone@somewhere.com < file_for_email_body

Mail with carbon and blind carbon -

mailx -m -s "Some Subject" somone@somewhere.com < file_for_email_body

(the file_for_email_body should look like this - )
~c someone_to_cc@somewhere.com
~b someone_to_bc@somewhere.com
The remainder of this file is the text body of the email.

Mail as another sender

echo "Hello" | mailx -m -s "Greeting" -r Santa.Claus@north_pole.com someone@somewhere.com

Mail with multiple attachments (The sentence "This is all you get." will appear as the body.)

mailx -m -s "Hello" someone@somewhere.com << END
`ux2dos /home/some_file | uuencode some_file.txt`
`ux2dos /home/some_other_file | uuencode some_other_file.txt`
This is all you get.
END

Cheers,

Renarios
Nothing is more successfull as failure