Sending mail using mailx

Sarma45

New Member
Hi guys,

I am trying to send automatic mails to some users using the mailx command. I have written a progress program for it. The format seems to be correct but the mails are not going. This is the code
define variable lc_command as char no-undo.
lc_command = "mailx".
if ip_attach <> "" then
lc_command = lc_command + " -a" + ip_attach.
output to "sndmail".
put unformatted
lc_command + " -s" + " " + ip_sub + " " + " -r" + " " + ip_from + " " + ip_to + " <<EOF" skip
ip_body skip
"EOF"
.

output close.

os-command silent chmod 777 sndmail.
os-command silent ./sndmail.
os-delete sndmail.

the ip_sub etc are input parameters and i am calling this program using gprun.i in another program.

{gprun.i ""xxsndemail.p""
"(input 'donotreply@abc.com',
input snd_mail_id ,
input '123@abc.com,
input snd_mail_sub,
input '',
input snd_mail_file)"}

Can ne 1 help me out y the mails arrent going to the users??
 

RealHeavyDude

Well-Known Member
We are using the code for years without a fuzz on Solaris

Code:
define variable mailHeader  as character  no-undo.
define variable mailRecipient  as character  no-undo.
define variable mailBodyFilePath  as character  no-undo.

unix silent value( substitute ( '/usr/bin/mailx -s "&1" "&2"  < "&3"', mailHeader, mailRecipient, mailBodyFilePath ) ).

Heavy Regards, RealHeavyDude.
 

TomBascom

Curmudgeon
If the posted code snippet is what you really have coded then I am surprised that it compiles (there seems to be at least a missing quote).

RHD's approach using SUBSTITUTE to build the command is generally stronger and easier to debug since it handles the unknown value much more gracefully.

I suggest logging the command that is built and the results of executing the command (don't forget to capture stderr) -- that should show you what is going wrong.
 
Top