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
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/ .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With