User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
email:forward [2025/03/02 16:28] – [Simple Email Setup] willyemail:forward [2026/04/14 07:37] (current) willy
Line 1: Line 1:
-====== Simple Email Setup ======+====== Z) Forwarding Email Setup ======
  
-The home server should always be able to send out emails for stuff like notifications. This is true even if you host your email server, because as i say [[:email|here]], you cannot self-host a real email server on your home server.+Assuming you already have a full email server (either hosted by you or you are using some third party service), you will need your **internal** server (the home server) to be able to send emails. This is true even if you host your email server, because as i say [[email:start|here]], you cannot self-host a real email server on your home server. 
 + 
 +The following must be performed on your internal server.
  
 The Gentoo default **mail-mta/nullmailer** package is more than enough. It should be already installed, otherwise emerge it: The Gentoo default **mail-mta/nullmailer** package is more than enough. It should be already installed, otherwise emerge it:
Line 8: Line 10:
 emerge mail-mta/nullmailer emerge mail-mta/nullmailer
 </code> </code>
 +
 +For future memory, Nullmailer home page is [[https://untroubled.org/nullmailer/|here]].
  
 ===== Configuration ===== ===== Configuration =====
  
-I assume you already have a mail domain somewhere linked to your **@mydomain.com**, and you have your own address as **myself@mydomain.com** and you created a specific mailbox called **home@mydomain.com** to manage any email sent from services.+Nullmailer is pretty much undocumented. [[https://www.troubleshooters.com/linux/nullmailer/|This]] blog post is mostly the only piece of documentation aroundeven Arch and Debian wiki's points to this old blog post.
  
-All the following files need to be under **/etc/nullmailer**:+First of all, you **must** already have a mail domain somewhere linked to your **@mydomain.com**, and you have your own address as **myself@mydomain.com** and you created a specific mailbox called **home@mydomain.com** to manage any email sent from services. 
 + 
 +The key point is to configure the home@mydomain.com as the source address to send all email from, which doesn't mean that the emails will actually come from that address, but that address will be used to deliver the emails. 
 + 
 +All the following files need to be under **/etc/nullmailer**
 + 
 +So, configure relay: 
 +<file - remotes> 
 +mail.mydomain.com smtp port=587 user=home@mydomain.com pass=**** starttls 
 +</file> 
 + 
 +Then define an //admin// email address to send important emails (errors, etc):
 <file - adminaddr> <file - adminaddr>
 myself@mydomain.com myself@mydomain.com
 </file> </file>
  
 +Now the tricky part, there are three files you must configure properly:
 +- defaultdomain: the domain you are sending email from
 +- defaulthost: you cannot leave this empty, and in my experiments the only working value is identical to defaultdomain content
 +- me:  again, not clear what this stand for, but it works if you replicate again the content of default domain.
 +
 +so:
 <file - defaultdomain> <file - defaultdomain>
 mydomain.com mydomain.com
Line 23: Line 44:
  
 <file - defaulthost> <file - defaulthost>
-mail+mydomain.com
 </file> </file>
  
 <file - me> <file - me>
-mail+mydomain.com
 </file> </file>
  
-<file - remotes> +Yeah, doesn't make much sense, but this is the only setup i found working for me.
-mail.mydomain.com smtp port=587 user=home@mydomain.com pass=**** starttls +
-</file>+
  
 ===== Usage ===== ===== Usage =====
  
-Try it from the command line:+In order for your root (or any user) emails to be sent to a specific address (example, myself@mydomain.com) you need to create a **~/.forward** file with the target email address in it: 
 +<file - .forward> 
 +myself@mydomain.com 
 +</file> 
 + 
 +Now, try it from the command line:
 <code bash> <code bash>
 (echo "Subject: test email"; echo "Hi! my nullmailer works...") | sendmail -F "Me Myself" -f myself@mydomain.com destination@otherdomain.de (echo "Subject: test email"; echo "Hi! my nullmailer works...") | sendmail -F "Me Myself" -f myself@mydomain.com destination@otherdomain.de
 </code> </code>
 +
 +Now test that the forward setting works as well:
 +<code bash>
 +echo "This is a test email from root" | mail -s "Test Subject" root
 +</code>
 +
 +you should receive both emails at myself@mydomain.com, even if the second one is directed a //root// on the local machine nullmailer will forward that.