ken bohnenkamp
5th February 2015, 23:02
I am trying to email from unix using the mailx command. Works great for one email address. I would like to email to multiple addresses. I tried setting up an email group in our email address book with multiple email addresses and then referenced this group in the mailx command but no luck. Anyone have a solution to send to multiple email addresses using the mailx command ?:confused:

mark_h
5th February 2015, 23:19
I do this in one file - only posted part of the first subroutine where I get all the email addresses.

select tppdm693.*
from tppdm693
where tppdm693._index1 = {:first.char}
and (tppdm693.type = tppdm.auth.appr or tppdm693.type = tppdm.auth.both)
selectdo
if not isspace(tppdm693.email) then
|07202004 Instead of multiple messages compile a list of user ids.
rec.addr = (addr.cnt>1) ? rec.addr & "," & strip$(tppdm693.email) : strip$(tppdm693.email)
addr.cnt = addr.cnt + 1
endif
selectempty
message("No approvers for the project.")
endselect
send.some.msg(rec.addr, tppdm690.cprj, " approved and created.")
}

function send.some.msg(string mail.addr(1024), domain tppdm.cprj mail.cprj, string mail.body(255))
{
string temp.file(255), msgtxt(255), cmd(2048)
long inputfile, rc

| Create temporary file to copy the PC file to
temp.file = creat.tmp.file$(bse.tmp.dir$())
temp.file = strip$(temp.file)
inputfile = seq.open(temp.file,"w")
msgtxt = "Project " & strip$(mail.cprj) & strip$(mail.body)
rc = seq.puts(msgtxt, inputfile)
rc = seq.flush(inputfile)
rc = seq.close(inputfile)

cmd = "mailx -s " & chr$(34) &"Project " & strip$(mail.cprj) & chr$(34)& " " & strip$(mail.addr) & "<" & temp.file
rc = shell(cmd, SHELL_NO_OUTPUT)
rc = seq.unlink(temp.file)
}

Han Brinkman
5th February 2015, 23:23
Normally you can supply multiple addresses to mailx as addresses.
Can you check 'man aliases'? That file can be used for creating/using mail groups as far as I know.

bhushanchanda
6th February 2015, 11:12
Hi,

You can try one of these -

LIST="recipient1@whatever.com recipient2@whatever.com recipient3@whatever.com recipient4@whatever.com"

mailx -s "Subject" $LIST < textfile

mailx -s "Subject" recipient1@whatever.com recipient2@whatever.com < textfile

cat textfile | mailx -s "Subject" recipient1@whatever.com recipient2@whatever.com

echo "This is my message" | mailx -s "Subject" recipient1@whatever.com recipient2@whatever.com

Or, as Han mentioned, you can go and set up an alias in /etc/aliases

list=email1@gmail.com,email2@gmail.com
EOF and just echo test|mailx list