Find the answer to your Linux question:
Results 1 to 5 of 5
Hello I'm running Ubuntu 7.04 Server to which I need to add e-mail capability. I installed Postfix through "apt-get install postfix", edited /etc/postfix/main.cf. Since I couldn't figure out how to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127

    Sending email from command line?


    Hello

    I'm running Ubuntu 7.04 Server to which I need to add e-mail capability. I installed Postfix through "apt-get install postfix", edited /etc/postfix/main.cf.

    Since I couldn't figure out how to use the sendmail command, I installed mailutils... but failed finding examples on how to use /usr/bin/mail with all the fields set from the command line:

    echo Call from customer X | mail -s Call from customer -f postfix@acme.com X fred@acme.com:

    ubuntu postfix/local[10214]: D24476343E1: to=<blah@ubuntu.acme>, relay=local, delay=0.19, delays=0.08/0.03/0/0.08, dsn=5.1.1, status=bounced (unknown user: "blah")

    ubuntu postfix/smtp[10213]: D24476343E1: to=<fred@acme.com>, relay=smtp.isp.tld [some_ip_here]:25, delay=0.37, delays=0.08/0.04/0.22/0.03, dsn=5.0.0, status=bounced (host smtp.isp.tld[some_ip_here] said: 504 <root@acme>: Sender address rejected: need fully-qualified address (in reply to MAIL FROM command))

    ubuntu postfix/local[10216]: D24476343E1: to=<from@ubuntu.acme>, relay=local, delay=0.96, delays=0.08/0.07/0/0.8, dsn=5.1.1, status=bounced (unknown user: "from")
    Is it possible to specify the FROM and TO fields from the command line, and if yes, how?

    Thank you.

  2. #2
    Linux Newbie
    Join Date
    Sep 2007
    Posts
    164
    hi,

    the To: field is specified as the last argument on your command line, so
    Code:
    echo "Call from customer X" | mail -s "Call from customer X" fred@acme.com
    ought to send mail to fred.

    afaik the From: field default to the user who is sending the mail and there is
    no option to change this -- in my view, this makes sense because else forgery
    of mails would be too easy (it's easy enough though).

    cheers, kai

  3. #3
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127
    Quote Originally Posted by kai12 View Post
    afaik the From: field default to the user who is sending the mail and there is no option to change this
    I'm surprised that command-line mailers don't let the user change the From field, as sending notifications through e-mail is a common task.

    Guess I'll have to write a script for this.

    Thanks for the tip.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2007
    Posts
    1

    Question

    You can specify the from field from the command line in Mail.

    After specifying the to email address add -- -f from_email_address

    See an example in this post on mindspill technology blog

    Cheers,
    Mike

  6. #5
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127
    Quote Originally Posted by mikelupu View Post
    You can specify the from field from the command line in Mail.
    Knew there had to be a way Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •