LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2012, 03:45 AM   #1
roopakl
Member
 
Registered: Sep 2011
Posts: 95

Rep: Reputation: Disabled
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.
 
Old 08-02-2012, 04:04 AM   #2
Celyr
Member
 
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 321

Rep: Reputation: 81
can you try
Code:
mail -s "Test" -c cc@domain.tld to@domain.tld
 
Old 08-02-2012, 06:24 AM   #3
roopakl
Member
 
Registered: Sep 2011
Posts: 95

Original Poster
Rep: Reputation: Disabled
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.

Last edited by roopakl; 08-02-2012 at 06:25 AM.
 
Old 08-02-2012, 06:45 AM   #4
Celyr
Member
 
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 321

Rep: Reputation: 81
It works to me, just tried, can you tell the output of
Code:
mail -V
 
Old 08-02-2012, 08:08 AM   #5
roopakl
Member
 
Registered: Sep 2011
Posts: 95

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.
But it is not working for me.
Code:
$ mail -V
mail (GNU Mailutils 2.2)
 
Old 08-02-2012, 08:34 AM   #6
Celyr
Member
 
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 321

Rep: Reputation: 81
Because you have this mail http://mailutils.org/manual/mailutils.html#SEC69
try to use mailx with the same syntax
 
1 members found this post helpful.
Old 08-04-2012, 07:51 AM   #7
roopakl
Member
 
Registered: Sep 2011
Posts: 95

Original Poster
Rep: Reputation: Disabled
Thanks Celyr,
It is working.
 
Old 07-15-2019, 03:56 PM   #8
barnarasta
Member
 
Registered: Oct 2012
Location: Spain
Distribution: Debian Squeeze-Wheezy-stretch-Buster \/ Unix SCO 5.7. in production, not for play.
Posts: 38

Rep: Reputation: 1
debian stretch
$ mail -V
mail (GNU Mailutils) 3.1.1

The options of "-c", or "-b" do not work.
 
Old 07-15-2019, 05:26 PM   #9
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by barnarasta View Post
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
 
Old 07-16-2019, 03:03 AM   #10
barnarasta
Member
 
Registered: Oct 2012
Location: Spain
Distribution: Debian Squeeze-Wheezy-stretch-Buster \/ Unix SCO 5.7. in production, not for play.
Posts: 38

Rep: Reputation: 1
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
 
Old 07-16-2019, 10:35 AM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by barnarasta View Post
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.

Last edited by scasey; 07-16-2019 at 10:36 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian etch - Unable to send mail from command line or from php mail command lqforumuser Linux - Newbie 1 03-01-2009 06:56 AM
Unable to send emails using mail command alpha01 Linux - Server 13 08-29-2008 06:11 PM
can mail command be used to send mail onto global mail servers like yahoo etc dale_chip Linux - Newbie 4 08-12-2008 08:33 AM
unable to send mail using Mail command navin_karnam Linux - Newbie 3 05-13-2008 02:21 AM
Unable to send mail using mail command faruque.ahmed Linux - Software 1 02-03-2007 10:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration