-1

I have recently setup a mail server on my Ubuntu Desktop 16.10, and I made a script that when a specific user logs in, they will execute the script instead of bash. Here is the script:

#!/bin/bash
while [ true ]
do
    echo -n "To: "
    read To
    echo -n "Subject: "
    read Subject
    echo -n "Attachments [y/N]: "
    read AttachYN
    if [[ $AttachYN == "" || $AttachYN == "n" || $AttachYN == "N" ]]
    then
        mail "$To" -s "$Subject"
        exit
    elif [[ $AttachYN == "y" || $AttachYN == "Y"  ]]
    then
        echo -n "File path: "
        read File
        mail "$To" -s "$Subject" -A "$file"
        exit
    else
        echo "Incorrect character, must be y, Y, n, N, or blank for default [n]"
    fi
done

Upon execution, it asks for Cc: input, but I don't want this, as I don't use Cc.

How do I remove this?

Thanks

MaliciouZzHD
  • 1
  • 1
  • 3

2 Answers2

2

Change the command sending the email like this:

mail "$To" -s "$Subject" < /dev/null

It will do it for you. If you later decide that you need a Cc: recipient, simply add it with -c switch to the mail command. You can read it from a command prompt, like you do with the recipient and the subject.

13dimitar
  • 2,508
  • 1
  • 13
  • 15
2

You can change this by setting the askcc option to False.

echo "set askcc=False;" >> ~/.mailrc

This will append the option to the .mailrc file in your homedirectory. If no config file exists it will be created.

If you run the command under a different user, for example under cron, you will have to set this for the user that runs the command.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89