Find the answer to your Linux question:
Results 1 to 4 of 4
There is a command called "mail" that I was trying to use, where you can email a textfile or message to an e-mail address, but I can't seem to get ...
  1. #1
    Linux Newbie
    Join Date
    Sep 2006
    Location
    Arizona
    Posts
    123

    Question command line e-mailing

    There is a command called "mail" that I was trying to use, where you can email a textfile or message to an e-mail address, but I can't seem to get it to work. The syntax is:

    mail <options> <email address> < <textfile>
    I tried this but it wouldn't send anything to my e-mail address ( I use yahoo mail)
    Also you can do:
    mail <options> <email address> (then hit enter)
    (then type a message here followed by cntrl+d to send)

    -but I was wondering if you could simply do it all on the same line(because I want to use it in a script), without having to hit cntrl+d. For example, would this work?:
    mail -s "This is the subject" 1@2.com "This is my one line message" <enter>

    any help on getting it to work would be awesome, or if you know any other commands I could use for this type of job. Thanks

  2. #2
    Just Joined!
    Join Date
    Oct 2006
    Posts
    6
    Go to System/Administration/Sever Settings/Services to make sure the SendMail MTA is running. If you are not using SendMail as your MTA, you need to make sure that MTA is running. Many people like using Postfix as an alternative MTA.

    For the Cont-D, you can try "here" documents. But the problem is how to enter cont-D in here document?

  3. #3
    Just Joined!
    Join Date
    Oct 2006
    Posts
    4
    Quote Originally Posted by infinet_e
    There is a command called "mail" that I was trying to use, where you can email a textfile or message to an e-mail address, but I can't seem to get it to work. The syntax is:

    mail <options> <email address> < <textfile>
    I tried this but it wouldn't send anything to my e-mail address ( I use yahoo mail)
    Also you can do:
    mail <options> <email address> (then hit enter)
    (then type a message here followed by cntrl+d to send)

    -but I was wondering if you could simply do it all on the same line(because I want to use it in a script), without having to hit cntrl+d. For example, would this work?:
    mail -s "This is the subject" 1@2.com "This is my one line message" <enter>

    any help on getting it to work would be awesome, or if you know any other commands I could use for this type of job. Thanks

    try 'mailq', you can see what are the errors.


    --
    Vladimir
    http://unix-news.blogspot.com

  4. #4
    Just Joined!
    Join Date
    Oct 2006
    Location
    Burnsville, Minnesota
    Posts
    4
    Try:

    Code:
    echo "This is my one line message" | mail -s "This is the subject" 1@2.com

Posting Permissions

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