Linux user account email

How to change Ubuntu user email address

My Ubuntu droplet is sending emails for things like cron output to email address my-user-name@ubuntu. The emails pile up in file /var/mail/my-user-name. How can I change this so the emails go to my external email address instead?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You can forward root’s mail inbox to your email address. To do this, you can open the /etc/aliases file with your editor. You will find this inside the file.

# See man 5 aliases for format postmaster: root 

Add the following line to the file. This will forward all emails generated from your system that is sent to root to your specified email address.

# See man 5 aliases for format postmaster: root root: user@youremaildomain.com 

Afterward, save and close the file. Finally, run the newaliases command in your terminal to activate the change. Hope this could be useful. Do not forget to check your Spam folder if you do not receive the expected emails in your inbox.

Источник

How to create an email account/address in Linux terminal? [closed]

Is it possible to create an email account under Linux* in the terminal? I’ve been looking to see if it is possible to generate email account dynamically for user registration purposes with my website. I’ve found lots of valuable resources on stack overflow and elsewhere regarding sending and receiving email, but none in regard to actually creating an account.

you might also consider telling people what your mailserver is running and how it is configured. smtp? pop? imap? etc.. do users of email have local PAM authed accounts? is it from an ldap directory?

1 Answer 1

To answer your question, it is possible to create an email account/address via the command line on a Linux/Unix system.

The first step is to create a user account on that system for the user in question. There are different ways to do this. I found this guide, The Ultimate Guide to Create Users in Linux/Unix, to be one of the better overviews.

Читайте также:  Забыл пароль от пользователя линукс

The next step requires understanding that email on Linux systems is often handled by two different systems/commands.

First is sending email. This is done quite often via sendmail. If a user can execute sendmail, then they can send mail via smtp to the world. This overly simplifies things, but it provides enough to get you started.

Receiving mail on the system and its delivery to users depends on the mail system and protocols being used. If you are using postfix, then the following article shows how to setup an email account.

My answer assumes you are not using LDAP or another directory service to maintain users.

This question probably belongs over in serverfault. I couldn’t find an exact match to it over there, so I answered it here and flagged it to be moved.

Источник

How do I create a local mail account?

I want to create a local mail account suitable for apt-listchanges. In other words, local services will send mail to local@localhost (?) and I should be able to check that mailbox using a regular mail client (Thunderbird, Geany. ) This would preferably be a «system» account rather than a «user» account, but if userland apps can’t access that, a «user» account will do.

2 Answers 2

I’m not sure I understand what you mean by system and user accounts but if you’re asking how to handle local e-mail on Linux it’s quite simple. I don’t use Ubuntu on the daily basis but I’ve just run the following in the virtual machine:

$ sudo apt-get install sendmail 

sendmail is the name of the SMTP server that will deliver e-mails.

mutt is the name of the Mail User Agent that we’ll use to read mail.

Make sure that sendmail is running:

$ ps aux | grep '[s]endmail' root 31687 0.0 0.1 108964 5408 ? Ss 19:24 0:00 sendmail: MTA: accepting connections 

Send a test e-mail to yourself:

$ sendmail -i $(whoami) Subject: test e-mail > > HELLO > MAIL_END 

Note that after pressing Enter you get:

You have new mail in /var/mail/

Use mutt to read mail, for example:

Actually, when using mutt you don’t even have to use -f :

is enough as mutt will try to open $MAIL . In Ubuntu it’s defined by default:

On a Debian-based system you should already have exim4 which provides the sendmail utility. Configure it as follows:

1. Confirm FQDN

exim4 requires a «fully qualified» domain name for your local machine, which just means it needs a dot in it. Confirm this with the following:

These will return your machine name and your FQDN. By default your FQDN is exactly the same as your machine name and does not contain a dot, and you need to change it.

(If it is different and contains a dot, skip step 2.)

Читайте также:  Linux bash script file

2. Modify hosts file

We will now set your FQDN. To do this modify your hosts file:

You should see the following lines in the file (gaps are tabs):

127.0.0.1 localhost 127.0.1.1 HOSTNAME 
127.0.0.1 localhost 127.0.1.1 mail.localhost HOSTNAME 

. then save and exit. Repeat step one to confirm that your hostname remains the same, and your FQDN has been updated.

3. Configure exim4

Configure exim4 as follows:

sudo dpkg-reconfigure exim4-config 

In the questions that follow select the following options (and otherwise select the defaults):

  • «local delivery only; not on a network»
  • System mail name: «mail.localhost»
  • Other destinations for which mail is accepted: «mail.localhost»
  • Keep number of DNS queries minimal? Yes
  • Delivery method: mbox format in /var/mail
  • Where to send root and postmaster mail: USERNAME@localhost
    • Now system messages will be sent to your user account and you don’t need special permissions to access them

    To test, you can send a local email with mail USERNAME@localhost. Fill in the prompts as follows

    $ mail USERNAME@localhost Cc: Subject: test subject test body

    You can confirm the message has been received by typing mail . Hit Q to quit the text-based mail client.

    5. Configure MUA GUI

    Now configure your preferred GUI client for mbox access, and check that your test message also appears in your inbox there.

    Источник

    get the default email from the user on a Linux box

    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

    Even if you went to all of the effort to parse the various configuration files to determine the email address(es) it’s very likely the user will have multiple accounts and you’d have to prompt them to choose. A better question might be how to validate the email address chosen.

    10 Answers 10

    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.

    Nobody’s mentioned the GECOS fields in the /etc/passwd file.

    You’ll notice that the fifth field in your entry in /etc/passwd is either blank, or a comma-separated list the first element of which is your full name. Originally in Bell Labs (before the days of email) the GECOS fields were:

    1. User’s full name (or application name, if the account is for a program)
    2. Building and room number or contact person
    3. Office telephone number
    4. Any other contact information (pager number, fax, etc.)

    Some Linux distributions store the user’s default email address in the 4th GECOS field, and if your system doesn’t do this by default, you can set it up yourself. Ordinary users without superuser privilege can edit their GECOS fields using the command line command chfn. To access this field, you can then do

    grep $: /etc/passwd | awk -F\: '' | awk -F\, '' 

    or whatever floats your boat in your language of choice (No, I am NOT going to write C. This is the twenty-first century!).

    Источник

    On Linux, what is the «mail» user account for?

    There’s an account mail and a group by the same name on my system, what’s its purpose ? It owns the /var/spool/mail directory (empty currently). I plan to use that directory, as well as that user to own the files of my «virtual» (ie, not tied to any real user account on the system) email accounts (instead of creating yet another user), is there anything wrong with that ? I’ve searched already but sadly, Google only brings up results either about the mail command or how-tos about how to create mail user accounts (install an MTA, etc).

    Do you have sendmail or postfix installed? I guess the mail user is a standard user on Linux systems. I see it on my local Mint desktop and on a Centos machine.

    Postfix is installed but runs under its own «postfix» (as well as a bunch of other users like «postdrop»).

    I’m mainly asking whether some program that I’m not aware of can get this «mail» user’s privileges and access the mail I’m going to store in /var/spool/mail .

    If you don’t know what it’s used for, and if it’s there, don’t mess with it. Create your own folder and use that!

    1 Answer 1

    Rule of thumb when when dealing with system administrator user accounts (those that UIDs range from 1-99) should never be touched (unless you know 100% what you are doing). These user accounts tend to be needed for important system functions.

    UIDs 1 through 99 are traditionally reserved for special system users (sometimes called pseudo-users), such as wheel, daemon, lp, operator, news, mail, etc. These users are administrators who do not need total root powers, but who perform some administrative tasks and thus need more privileges than those given to ordinary users.

    Sendmail for example, is one such application that uses the mail user if the default options are left intact. The DefaultUser option in Redhat 7 defines the userID as 8 and the groupID as 12 . These values match with the mail user in your /etc/passwd file:

    mail:x:8:12:mail:/var/spool/mail:/sbin/nologin 

    Источник

Оцените статью
Adblock
detector