LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sendmail alias not working (https://www.linuxquestions.org/questions/linux-newbie-8/sendmail-alias-not-working-4175538734/)

RagingRaven 04-04-2015 06:17 AM

sendmail alias not working
 
I'm trying to send all root's mails to an external e-mailaddress, but for some reason I can't get it to work.

I've edited /etc/aliases with the following rule:

root: <myexternal@email.address>

and run newaliasses after, which would run without any errors.

I can run: echo "Testing" | mail -s "Server Testing" <myexternal@email.address>
just fine without any issue and it's being delivered correctly to my external address.

But when I run: echo "Testing" | mail -s "Server Testing" root

I (first) get a "Deferred: 451 Temporary local problem - please try again later" error and when I then run: "Sendmail -OTimeout.hoststatus=0m -q -v" to flush the mailqueue it says everything is ok, but I then get a message saying I have new mail in /var/spool/mail/root and I don't get the mail on my external e-mailaddress.

I have no clue where to look next, hopefully you guys can point me in the right direction.

Just for completeness: I use mageia release 4 (x86_x64).

RagingRaven 04-04-2015 08:36 AM

I'm not sure if linux newbie is the right place for this topic ?
It seems it's more than a simple question, seeing as nobody responded yet?

RagingRaven 04-07-2015 02:25 AM

Hmm...nobody?

I thought there might be an issue with the hosts file, where I gave my localhost a name in the same domain as the domain I wanted to send my mail to.
So I changed this to another name to check and the Deferred message no longer showed, but the mails still don't go to the external address, but get deliverd locally.

It almost seems as though my alias file is totally ignored.

bathory 04-07-2015 03:10 AM

Quote:

It almost seems as though my alias file is totally ignored.
Could be that you're editing the wrong aliases file.
Check whether you're running indeed sendmail and it's not using /etc/mail/aliases, or you're running the postfix sendmail replacement in which case it uses /etc/postfix/aliases

RagingRaven 04-07-2015 03:32 AM

Thanks for answering.

I'm pretty sure it's sendmail, but I checked just to be sure:

man postfix: no manual entry for postfix
man sendmail: opens sendmail manual

which sendmail: /usr/sbin/sendmail

updatedb (to make sure my locate database is up to date)
locate main.cf -> no results
locate sendmail.cf -> /etc/mail/sendmail.cf

So it appears it is indeed sendmail, but seeing as you were pointing to /etc/mail/aliases instead of /etc/aliases and the sendmail.cf file is also in /etc/mail/ I went and had a look.

In the folder /etc/mail/ there is no aliases file so I did a locate aliases -> the only file I see that has anything to do with mail is /etc/aliases and /etc/aliases.db

So from what I gather, I'm using the right file.
I did read somewhere that aliases only work when using the sendmail daemon, but the linked topic no longer works, so I have no idea if this has anything to do with it?
edit: read some more, but from what I gather sendmail should run as daemon per default (it shows up when doing ps aux | grep sendmail).

RagingRaven 04-07-2015 04:05 AM

Ok so I tried using a .forward file in the user folder and this works so I've at least got a working situation.

But it seems more of a workaround rather than an actual solution, so I'd appreciate it if somebody could still help me figure this out.

bathory 04-07-2015 04:06 AM

Have a look in /etc/mail/sendmail.cf for the AliasFile option, that gives the actual aliases file

RagingRaven 04-07-2015 04:11 AM

sendmail.cf says:
AliasFile=/etc/aliases

To me it seems everything points to the aliases.db not being updated or being ignored.
Especially since forwarding with a .forward does work.

Is there a way to see what is inside the aliases.db file? because a normal editor doesn't work (obviously).

bathory 04-07-2015 05:12 AM

What is the output of
Code:

sendmail -bv root
Quote:

Is there a way to see what is inside the aliases.db file? because a normal editor doesn't work (obviously).
You can use
Code:

makemap -u hash /etc/aliases.db

RagingRaven 04-07-2015 05:24 AM

sendmail -bv root:
<myexternal@e-mail.address>... deliverable: mailer esmtp, host <myexternal.domain>.. user <myexternal@e-mail.address>

obviously <myexternal@e-mail.address> is my actuall address without the <> and <myexternal.domain> is the corresponding domain.

So that looks ok to me.

makemap -u hash /etc/aliases.db shows no entry for my external address, so now we are getting somewhere.

it seems 'newaliases' isn't updating aliases.db

RagingRaven 04-07-2015 05:33 AM

Just to be sure I reran newaliases, but nothing updated to aliases.db

I don't know why, but I created a fresh aliases file, added every relevant line and ran newaliases again.
Now it seems my address got added.

I've no idea why it wouldn't do it in the old file, because the root: <myaddress> line is exactly the same in both files, so it almost seems as if it got corrupted somehow.

Doesn't really matter, it works!
Thanks bathory for pointing me in the right direction!


All times are GMT -5. The time now is 02:30 PM.