In a Ubuntu os, with sendmail installed (maybe as default installed package) but not configured, I tried to type both

echo "Text message" | mail <dest_ip_address>\!dest_user


echo "Text message" | mail dest_user@<dest_ip_address>

where <dest_ip_address> was in the same LAN as the local machine. But the mail was not sent. The sender receives an error mail which says

<user@<dest_ip_address>> (expanded from <<dest_ip_address>!dest_user@localhost>): bad address syntax

in the first case and a similar error in the second.

So the mail sender always considers the syntax referred to the local machine and it seems to ignore the specified <dest_ip_address>.

However, in the /etc/hosts there is a line for <dest_ip_address>, with

<dest_ip_address>    hostname

Is some configuration to be done in sendmail, or in the destination host? Or what else?

  • 1
    The default installed package is postfix and asks, during installation what kind of configuration you want. You need to re-configure this to get mail working in my experience. Did you get any message from mail? Can you post the relevant entries in /var/log/mail.log? – Anthon Dec 5 '14 at 13:46
  • @Anthon Yes, the message I got from mail was the error mail I was talking about. In /var/log/mail.log is written connect to <dest_ip_address>[<dest_ip_address>]:25: Connection refused. So the destination host should be configured to accept incoming mails. – BowPark Dec 5 '14 at 14:39
  • Exactly it looks like it is not listing on port 25. Try apt-get install postfix on that machine (if it is running Ubuntu as well). And watch in the /var/log/mail.log in the remote machine what happens with incoming mail if it doesn't immediately work. – Anthon Dec 5 '14 at 14:45

If you want to send email to a user at an IP address, you need to enclose the address in brackets, e.g. dest_user@[ip.ad.dr.ess].

Whether that addressing will be accepted by the receiving server is another issue. My mail servers don't accept email addressed to it IP address.

  • Thank you, now the e-mail is at least accepted. Read my comment to @Anthon for the error that now the receiver host causes: maybe some configuration is to be made there. – BowPark Dec 5 '14 at 14:40

Often you can look at the headers of the bounced mail about what has gone (wrong) under way, how far the mail got and which machine rejected it (or was offline).

If you have access to the sending and/or receiving machine's /var/log/mail.log check those for messages to make you start looking for possible configuration problems on the right machine.

Looking at the log files is the most easy approach, but you can of course also telnet into port 25 of the receiving machine to check if it will accept emails (using the right commmands).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.