Score:0

mail works, but sendmail doesn't! (Postfix)

ph flag

I installed postfix on a server and when I send an email with the sendmail command it doesn't get delivered, but when I send with the mail command it does get delivered. What's worse, postfix logs claim it got delivered when using:

This is what the logs show for echo "test email" | sendmail [email protected]

Sep  4 14:33:03 howtocode1 postfix/pickup[271977]: 38418406E2: uid=0 from=<root>
Sep  4 14:33:03 howtocode1 postfix/cleanup[272164]: 38418406E2: message-id=<[email protected]>
Sep  4 14:33:03 howtocode1 postfix/qmgr[231761]: 38418406E2: from=<[email protected]>, size=295, nrcpt=1 (queue active)
Sep  4 14:33:03 howtocode1 postfix/smtp[272166]: 38418406E2: to=<[email protected]>, relay=mail2.mailinator.com[45.33.83.75]:25, delay=0.06, delays=0.03/0.01/0.01/0.01, dsn=2.0.0, status=sent (250 Ok)
Sep  4 14:33:03 howtocode1 postfix/qmgr[231761]: 38418406E2: removed

Obviously it looks right. But no mail ever gets delivered. But this one: echo "test email 2" | mail [email protected] works great! The mail gets sent!

So I don't understand why in the world them mail command works, but not sendmail. Any idea?

Michael Hampton avatar
cz flag
`sendmail` is not intended for interactive use. You're meant to use `mail`.
user3413723 avatar
ph flag
@MichaelHampton but why doesn't it work? Do you have any idea what's going on? I read the man page and it seems like it's supposed to work.
Michael Hampton avatar
cz flag
The command `sendmail` itself is designed for _other programs_ to send mail. You can certainly feed it the right options to get it to work, but if you're doing something interactively you really should instead use `mail` which is designed for that purpose.
Score:1
in flag

Ok, let's test it direct:

$ host -t mx mailinator.com
mailinator.com mail is handled by 1 mail.mailinator.com.
mailinator.com mail is handled by 1 mail2.mailinator.com.
➜  ~ telnet mail.mailinator.com 25
Trying 23.239.11.30...
Connected to mail.mailinator.com.
Escape character is '^]'.
220 mail.mailinator.com ESMTP Postfix
EHLO LutzWillek
250-mail.mailinator.com
250-8BITMIME
250-STARTTLS
250 Ok
MAIL FROM:<[email protected]>
250 Ok
RCPT TO:<[email protected]>
250 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test from command line

Hello. This is a test message.
.
250 Ok
Connection closed by foreign host.

This works, as the message can be seen in https://www.mailinator.com/v4/public/inboxes.jsp?to=sendmail

Your log shows that the message with id 38418406Ehas been sent as well, and that the remote server accepted this mail.

So just try it again, it will work.

Score:0
ph flag

Ok this is the weirderst thing ever. This does not work:

echo "Subject: 1hello people" | sendmail [email protected]

But this works:

echo "Subject: hello people
>this is the body" | sendmail [email protected]

So for some reason if there is no body, just a subject, it does not work. It claims it got sent, but somehow it isn't accepted or something. I tried sending to other places besides mailinator and had the same issue.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.