LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unable to send CC mail using mail command (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-send-cc-mail-using-mail-command-4175419931/)

roopakl 08-02-2012 03:45 AM

Unable to send CC mail using mail command
 
Hi All,
I am using Ubuntu 12.04 and I am not able to send mail as cc. Here is test file
Code:

$cat test-mail
#!/bin/bash
echo "This is a test mail."| mail -s "Testing CC" other@mydomain.com -c me@mydomain.com

And getting the below error
Code:

$bash test-mail
mail: invalid option -- 'c'
Try `mail --help' or `mail --usage' for more information.

So please help me how to send CC mails in bash shell script.
Thanks in advance for your kind help.

Celyr 08-02-2012 04:04 AM

can you try
Code:

mail -s "Test" -c cc@domain.tld to@domain.tld

roopakl 08-02-2012 06:24 AM

Thanks Celyr,
Quote:

mail -s "Test" -c cc@domain.tld to@domain.tld
I had already tried the above but it is not working and giving the same above error. Could you please help me in this.

Celyr 08-02-2012 06:45 AM

It works to me, just tried, can you tell the output of
Code:

mail -V

roopakl 08-02-2012 08:08 AM

Thanks for the reply.
But it is not working for me.
Code:

$ mail -V
mail (GNU Mailutils 2.2)


Celyr 08-02-2012 08:34 AM

Because you have this mail http://mailutils.org/manual/mailutils.html#SEC69
try to use mailx with the same syntax

roopakl 08-04-2012 07:51 AM

Thanks Celyr,
It is working.:)

barnarasta 07-15-2019 03:56 PM

debian stretch
$ mail -V
mail (GNU Mailutils) 3.1.1

The options of "-c", or "-b" do not work.
:(

scasey 07-15-2019 05:26 PM

Quote:

Originally Posted by barnarasta (Post 6015330)
debian stretch
$ mail -V
mail (GNU Mailutils) 3.1.1

The options of "-c", or "-b" do not work.
:(

You should probably start your own thread.

That said, what happens when you use those options? "do not work" doesn't give us anything to help you with.

I don't have that version, either. What does the man page say? man mail

barnarasta 07-16-2019 03:03 AM

It's true, maybe I should start a new thread,
but 'gogleando' the problem I found this and take advantage of it.

The problem is that I have several scripts made for 'wheezy' that work well, but in the migration to 'stretch' they give the following problem:

Quote:

$ echo 'hola'|mail -s "probando" uno@telefonica.net -c dos@telefonica.net
mail: unrecognized option '-c'
The man mail is still mentioning the possibility of using it, but it does not work.


Thank you

scasey 07-16-2019 10:35 AM

Quote:

Originally Posted by barnarasta (Post 6015449)
It's true, maybe I should start a new thread,
but 'gogleando' the problem I found this and take advantage of it.

The problem is that I have several scripts made for 'wheezy' that work well, but in the migration to 'stretch' they give the following problem:


The man mail is still mentioning the possibility of using it, but it does not work.


Thank you

My version's man page says
Code:

mail [-BDdEFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr] [-r from-addr] [-h hops] [-A account] [-S variable[=value]] to-addr . . .
which would suggest that the command should be
Code:

$ echo 'hola'|mail -s "probando" -c dos@telefonica.net uno@telefonica.net
that is, the To address is the last argument. Providing the To before the -c option is probably what's causing your error.

And yes, please start your own thread next time.


All times are GMT -5. The time now is 04:48 AM.