1

I have installed Ubuntu Bionic on my virtual machine and have an application set up.

Now what I need is to send emails from my own server.

I am trying to set up postfix to do that but nothing works. I have tried many tutorials but still no success....even worse - the more tutorials I try the more confused I get.

So what have I tried?

I used apt install mailutils to install postfix and I chose internet site When it asked for FQDM. I entered mydomain.com..

Here is the first question. Some tutorials say to change it to mail.mydomain.com . So is it supposed to be a subdomain? Do I need to create an A record to my DNS?

The I try to send an email:

email" | mail -s "This is the subject line" somemail@mail.com

But nothing happens...no mail in my mailbox and no mails in posfix queue.

  1. Is there a step by step tutorial for a complete beginner?

  2. Do I need to create a MX record pointing to my server?

  3. Do I need to create a TXT record? I read that that is how other mail servers validate a sender. If yes, then how to do it?

  4. So what do I have to do to send and email from my own server? At this point I don`t even need to receive and email - just send it

And I don`t need to use postfix... I can use whatever works.

Eliah Kagan
  • 117,780
Davis
  • 121
  • This should be all you need to do. – Jos May 29 '20 at 10:52
  • @Jos This is exaclty what I tried but still nothing – Davis May 29 '20 at 11:04
  • Then I suppose you have sent yourself an email as described in Step 3. Is there anything in /var/log/maillog or /var/log/mail that gives a clue? Also see this postfix debugging guide. – Jos May 29 '20 at 11:23
  • @Jos I don`t have maillog file... – Davis May 29 '20 at 11:39
  • Is the postfix server running? sudo systemctl status postfix – Jos May 29 '20 at 11:46
  • ● postfix.service - Postfix Mail Transport Agent Loaded: loaded (/lib/systemd/system/postfix.service; enabled; vendor preset: enabled) Active: active (exited) since Fri 2020-05-29 14:36:06 EEST; 22min ago Process: 10809 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 10809 (code=exited, status=0/SUCCESS) – Davis May 29 '20 at 12:01
  • If all you need to do is send email, do not get into the postfix flail. Just install nullmailer https://askubuntu.com/a/1124624/243321 It is so, so much easier. – Organic Marble May 29 '20 at 12:10

2 Answers2

3
  • Is there a step by step tutorial for a complete beginner?

    many , but nowadays you are better off using a solution like MODOBOA or MAILU in a docker container

  • Do I need to create a MX record pointing to my server?

to receive mails ? yes

to send mails ? no

more important : you need a spf record and preferably a reverse dns ( pointing from sending ip to hostname )

  • Do I need to create a TXT record? I read that that is how other mail servers validate a sender. If yes, then how to do it?

    basically at your dns provider /server , here is a good tutorial

  • So what do I have to do to send and email from my own server? At this point I don`t even need to receive and email - just send it

setup PF , PTR , add the domain to your mailserver and use the sendmail command you provided ,

if you only want to have "send via external account" functionality (e.g. from your gmail ) , use MSMTP and msmtp-mta, so you have the sendmail command and use a "normal" mailbox somwhere else without big config trouble

b1nch0
  • 106
  • Dude! The best answer I have received regarding this topic - a lot of good information. I am marking this as an answer! Thank you a lot! – Davis Jun 09 '20 at 14:27
1

An option you can consider is this guide: https://blog.terresquall.com/2022/01/setting-up-a-virtual-postfix-mail-server-part-1/

It is a 3-part series that covers how to set up a virtual mail server using Postfix. A virtual mail server is essentially a mail server without a mail box. Incoming emails are forwarded to another address (e.g. Gmail / Hotmail), and emails are sent out using a mail client (e.g. Gmail / Hotmail, again) that is configured to query the mail server (so that emails are sent using your domain address instead of Gmail / Hotmail's).

The guide covers the following:

  1. Setting up mail forwarding on your domain, so emails to your domain are forwarded to email address(es) of your choice.
  2. Setting up an authentication mechanism on your mail server so that other mail clients can connect to it to send emails (so that your email clients can send emails under your domain name)
  3. Setting up email authentication policies like SPF, DKIM and DMARC, so that the emails coming from your mail server have a minimal chance of being marked as spam.
John Doe
  • 231