Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have questions about mail,

  1. I am using following command on my linux account of my compnay

    mail -s 'Hi' username@gmail.com

But I dont receive any emails, where as did not receive any error while executing the above command, so whats going on and what is happening.

  1. what email id do mail use to send the email by default. Is there any way or command to print this by default user id.
share|improve this question
    
Can you include the contents of (or last 5-10 lines of) the /var/log/maillog file please? –  chown Sep 9 '11 at 20:04
    
Also, please run mailq and show the output of that command. –  chown Sep 9 '11 at 20:04
    
@chown Ok. I was using Ctrl-D. But now I tried using '.' but still it doesnt work. –  rkb Sep 9 '11 at 20:22
    
@chown: Output mailq; can not chdir(/var/spool/mqueue/): Permission denied Program mode requires special privileges, e.g., root or TrustedUser. –  rkb Sep 9 '11 at 20:23
    
Is there any way I could become TrustedUser other than root. –  rkb Sep 9 '11 at 20:25
show 2 more comments

migrated from stackoverflow.com Sep 9 '11 at 21:06

This question came from our site for professional and enthusiast programmers.

2 Answers

mail is a mail user agent (MUA), you also need a mail tranport agent (MTA), such as postfix, to deliver non-local mail. The MTA has to be configured appropriately, many ISPs require that mail be routed through their mail servers. This usually means configuring your MTA to treat theirs as smarthosts or relays rather than attempting to deliver mail directly to the mailserver for the recipient's domain.

Have you checked your MTA configuration and checked your logfiles for messages about delivery failures.

share|improve this answer
add comment

Suggestions:

You need to hit enter, then put a . on the next line, then hit enter again and the mail should get sent. Like so:

[root@host ~ ]# mail -s "test" me@gmail.com
This will be in the body of the email
Cc: me_cc@gmail.com
.
[root@host ~ ]# 

The . on its own line tells the mail command that you are done writing the body of the email and acts as an EOF for the command.


Another way to do it is:

[root@host ~ ]# echo "This will be the body of the email" | mail -s "This is the subject" me@gmail.com

And another method:

[root@host ~ ]# mail -s "This is the subject" me@gmail.com < /home/me/fileText_for_emailBody.log

This uses the contents of /home/me/fileText_for_emailBody.log as the body of the email.

share|improve this answer
    
I just stumbled on this because I'm having a similar problem but my e-mails are hanging while using your 3rd option with the < /path/to/file.txt addition to the mail command. If I use control+d or a period they do go through. I even put a lone period in the text file i'm using to see if that work work. And I'm stuck. –  mosiac Jul 26 '12 at 16:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.