Not able to send mail on my company's account but gmail in Linux 6.8

On Red Hat Enterprise Linux Server release 6.8.

I am to get the email from my LINUX box on gmail account but it fails on company domain.
getting status=sent for gmail. BUT

getting below error for company domain:

status=bounced
#5.1.8 Domain of sender address <root@xxxx.com> does not exist (in reply to MAIL FROM command))    

-- Please help :frowning:

Hi,

There are so many things that could be going on here. I'm guessing that you're attempting to send e-mail from your own Linux box, using its own local MTA (Postfix, sendmail, etc), and that when you try to send e-mail to your GMail account you get these bounce messages.

Again this is a pure guess since you've not really given us much to go on here, but if (for example) your Linux box has a hostname of foo.company.com, and you're logged in or otherwise running as 'root' at the time, then mail you send from the command line or otherwise directly through your own MTA will go out as 'root@company.com'.

Now, GMail (and many other mail services besides) tend to do all kinds of checking on incoming e-mail to determine whether or not it's valid. One of these checks can be to determine if the apparent e-mail address the sender is sending as actually exists. Now, if your company doesn't have an e-mail address called 'root@company.com' it will fail this check, and GMail will bounce the mail.

Note that if this is what is happening then this is 100% correct and valid behaviour. You almost certainly don't want to be sending mail out from your workstation as 'root@company.com'. Instead, in whatever script or command or program you're sending your mail, you need to set a valid 'From:' address to use instead. That way, mail has a better chance of going out succesfully.

Also, if your company has an e-mail gateway for sending outbound mail from, configure your own local MTA (Sendmail, postfix, etc) to be a smart relay, instead passing all its own local mail to that relay. Or just directly send out to that corporate mail relay instead, rather than submitting e-mail locally. That would be best practice in general, if you have such a facility to make use of.

Hope this helps.

Thank !! but I can receive the email on gmail account but not company account from the same server.!!

Hi,

OK. Well, the explanation could be the same. In fact it would make even more sense that your own company's mail servers would reject the mail, if it is being sent as 'root@company.com' and that address does not exist or you don't have permission to use it.

Where is the bounce report actually coming from - as in, from what mail server ? Are you sending the bounced mail using a desktop client like Thunderbird or something similar, or by command-line use of mail, mailx, sendmail, etc ? Also, regardless of what you're using to send, are you setting a valid "From:" address that actually exists ?

Thanks....Yes , I am using mail and sendmail utility from CLI mode, and the logs , I am getting from /var/log/maillog.

I am in with root user and send the both mail from the same root user , one is working and another not, don't know how it could be a permission problem. Please explain it.

Hi,

OK. The two main questions I asked still stand: where are the bounce reports coming from, and are you setting a valid "From:" address ? As previously mentioned, it's very unlikely indeed that root@ is a valid e-mail address for your domain, and so your own company mail servers are almost certainly rejecting your mail because of that.

Got bounce report from /var/log/maillog. and could you please let me know know to check valid address on this server. as I am new on mail server.

Hi,

I was more meaning which server was generating the error telling you the address did not exist ? You would indeed see the error in /var/log/maillog , but that file will contain everything your local MTA (Sendmail, Postfix, etc) wants to log. What's important for debugging SMTP issues firstly is knowing where the problem is.

In any case, I think it's probably safe to assume that the error you're getting means what it says it does - that root@ is not a valid e-mail address. So, returning to my other question. What is the exact command you are using, in full, to send the mail ? If we can see a full and complete excerpt of the code you are using, we can then advise what might be going wrong.

But in general, you are going to want to set the From: address for any mail you ever send to be valid, if the mail is ever going to be leaving the server on which it is created at any rate.

Now, the behaviour of the mail command is highly version and OS-specific, but on my local machine (running Ubuntu 16.04 LTS x86_64) the following syntax works for me to set a valid From: address. Note that I have removed or changed some of the e-mail headers from the output for privacy reasons, so you will see more headers than just these ones (or you should).

$ mail -s "This is a test" -a "From: example@test.com" unixforum@localhost
Cc:
This is a test.  We should see the From: address is set to a valid SMTP address, and not my local UNIX username.
$ mail
"/var/mail/unixforum": 1 message 1 new
>N   1 example@test.com   Wed Mar  8 07:59  16/820   This is a test
? 1
Return-Path: <example@test.com>
Date: Wed, 8 Mar 2017 07:58:59 GMT
Subject: This is a test
From: example@test.com
To: <unixforum@localhost>
X-Mailer: mail (GNU Mailutils 2.99.99)

This is a test.  We should see the From: address is set to a valid SMTP address, and not my local UNIX username.
? d 1
? q
Held 0 messages in /var/mail/unixforum
$

Normally you'd want a From: header to look more like From: An Example <test@example.com> , but this is just a quick example to demonstrate the principle.

Hope this helps.

I am really glad to see your help.
I am using below command to send the mail from the server where postfix has been installed
echo "hi" | mail -s "test" username@xyz.com
and on the same server , I am getting below erroe from the location

cat /var/log/maillog

Mar  8 08:07:33 ab-boot-ora postfix/pickup[31850]: 5BD2D542B34: uid=0 from=<root>
Mar  8 08:07:33 ab-boot-ora postfix/cleanup[38600]: 5BD2D542B34: message-id=<20170308080733.5BD2D542B34@localhost>
Mar  8 08:07:33 ab-boot-ora postfix/qmgr[20449]: 5BD2D542B34: from=<root@localhost.localdomain>, size=424, nrcpt=1 (queue active)
Mar  8 08:07:34 ab-boot-ora postfix/smtp[38602]: 5BD2D542B34: to=<username@abc.com>, relay=mx2.abc.com[]:25, delay=1.4, delays=0.03/0.01/1.2/0.11, dsn=5.0.0, status=bounced (host mx2.abc.com[69.150.27.74] said: 553 #5.1.8 Domain of sender address <root@localhost.localdomain> does not exist (in reply to MAIL FROM command))
Mar  8 08:07:34 ab-boot-ora postfix/cleanup[38600]: CA9A7542B3A: message-id=<20170308080734.CA9A7542B3A@localhost>
Mar  8 08:07:34 ab-boot-ora postfix/bounce[38604]: 5BD2D542B34: sender non-delivery notification: CA9A7542B3A
Mar  8 08:07:34 ab-boot-ora postfix/qmgr[20449]: CA9A7542B3A: from=<>, size=2356, nrcpt=1 (queue active)
Mar  8 08:07:34 ab-boot-ora postfix/qmgr[20449]: 5BD2D542B34: removed
Mar  8 08:07:34 ab-boot-ora postfix/local[38605]: CA9A7542B3A: to=<root@localhost.localdomain>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Mar  8 08:07:34 ab-boot-ora postfix/qmgr[20449]: CA9A7542B3A: removed

Hi,

OK, thanks. The problem does indeed appear to be that you are sending mail as root@localhost.localdomain , which external mail servers will indeed rightly reject as being invalid (because it is).

Try setting the From: header to something valid using the same technique as in my previous example, and see how you get on.

Thanks, I used below cli
/usr/sbin/sendmail -f username@domain.com username@domain.com

now logs has chnaged got status sent but didnt received mail.

Mar  8 12:21:17 Ak-Soot-ora postfix/pickup[58644]: 328EC542B3A: uid=0 from=<username@domain.com>
Mar  8 12:21:17 Ak-Soot-ora postfix/cleanup[59848]: 328EC542B3A: message-id=<20170308122117.328EC542B3A@Ak-Soot-ora.domain.com>
Mar  8 12:21:17 Ak-Soot-ora postfix/qmgr[41697]: 328EC542B3A: from=<username@domain.com>, size=302, nrcpt=1 (queue active)
Mar  8 12:21:25 Ak-Soot-ora postfix/smtp[59850]: 328EC542B3A: to=<username@domain.com>, relay=mx4.domain.com[]:25, delay=12, delays=3.9/0/6.8/1.7, dsn=2.0.0, status=sent (250 ok:  Message 22911887 accepted)
Mar  8 12:21:25 Ak-Soot-ora postfix/qmgr[41697]: 328EC542B3A: removed

Hi,

Well, that indicates your mail was successfully delivered to the mail server which was the next hop in the chain. You'd have to check the mail logs on that server (or ask whoever manages that server to check them, if it isn't you) to see what became of your e-mail after that server took delivery of it.

Above logs i captured from /var/log/maillog..so mail logs is something different ?

---------- Post updated at 08:48 AM ---------- Previous update was at 08:42 AM ----------

could you please remove ip address from the above reply ..Thanks

Hi,

The excerpt of /var/log/maillog which you posted showed the message being passed from your own system, to another system. You now need to log on to that other system (the one whose IP I've now removed from the previous post, as per your request), and see what it then did with the mail. If it's a UNIX-style system then it will most likely have a /var/log/maillog of its own. If it's something else (Microsoft Exchange, say) then it will have another mechanism for checking what happened to the mail.

E-mail delivery is a chain of events leading from the sending server all the way through to the server that finally knows what to actually do with the mail in question, often with other intermediary servers in between. You have to trace what happened to the mail at each step along its journey to its final destination to figure out why it's not been delivered. The logs on your own workstation won't be enough, since all they show is that your local MTA did its job, and passed the mail on to the server that it believed would know what to do with it next.

1 Like

I really appreciate !! will come back to u if required, hope u will be there :slight_smile:

---------- Post updated 03-09-17 at 03:02 AM ---------- Previous update was 03-08-17 at 09:04 AM ----------

Hi again, with your help i am able to send email but once i tried to send it with subject and attachment so attachment is sending but without subject. Need your attention here again !!

Try:

{   echo "Subject: Testing"
    uuencode MY_TEST_FILE.xls MY_TEST_FILE.xls
} | /usr/sbin/sendmail -f from@abc.com to@abc.com

Great .. It works..