Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the default email from the user on a Linux box

Tags:

c

linux

email

Is there any way to programmatically get the current user's email address? I know the email is usually user@hostname but is there any I can get the email? I know how to get the username and the hostname so I can build it myself, but I want to be sure that I get the email address even when the email is not user@hostname.

Code in C is appreciated.

Thanks

like image 269
Uri Avatar asked Nov 11 '09 16:11

Uri


People also ask

What is the path to the user mail in Linux?

Standard Linux installation provide a maildir in /var/spool/mail/$user (that's actually a single file holding all emails, not a "mail directory"), soft-linked by /var/mail/ .

In what directory are email inboxes stored by default in Linux?

Incoming mail is stored in the system mailbox. By default, a user's system mailbox is a file located in the /var/spool/mail directory.

How do I find my Unix email?

You don't need a specific command to receive mail, mail is automatically delivered and stored on the machine's filesystem (usually on /var/spool/mail/username ) by the appropriate Mail Delivery Agent.


1 Answers

There is no such standard mapping of user account to email address - at least not for ordinary /etc/passwd derived accounts. Consider that a user might not even have an email address.

like image 71
Douglas Leeder Avatar answered Sep 17 '22 08:09

Douglas Leeder