Question

Why can't send mail with command mail or mailx?

Posted August 19, 2015 4.7k views
Email

I have installed postfix and start postfix service .

I can send email from user root to user debian8 by telnet command.

root@pengsir:/home/debian8# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 pengsir.hfi ESMTP Postfix (Debian/GNU)
ehlo mail
250-pengsir.hfi
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:<root>
250 2.1.0 Ok
rcpt to:<debian8>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
this is a test mail send from root
.
250 2.0.0 Ok: queued as CA53CF82C3
quit
221 2.0.0 Bye
Connection closed by foreign host.

Let’s change user debian8 to receive the email.

root@pengsir:/home/debian8# su debian8
debian8@pengsir:~$ mail
Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/debian8": 1 messages 1 new 1 unread
 N  1 root@pengsir.hfi   Wed Aug 19 10:10   13/441   
& 1
Message 1:
From root@pengsir.hfi  Wed Aug 19 10:10:56 2015
X-Original-To: debian8
Date: Wed, 19 Aug 2015 10:10:23 +0800 (HKT)
From: root@pengsir.hfi

this is a test mail send from root

& quit

It is strange that i can not send email with mail or mailx command.

mail -s 'test_for_postfix'  debian8@pengsir.hfi
mailx -s 'test_for_postfix'  debian8@pengsir.hfi

It look like that the cursor will be stop in the console forever ,no error info putput when to execute the two commands.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

I got the answer: input something and press ctrl+d and input something for cc , then press enter.

Submit an Answer