I am inexperienced in configuring mail systems.
I am using Ubuntu #54~20.04.1-Ubuntu
.
How can I configure my computer to send emails using a gmail account, with postfix
?
I mean not to have any other paid mail server or domain involved (EDIT: I could configure my PC to work as a server, but I mean to avoid requiring paid registration in DNSs).
Is this is even possible?
I tried a few things, which I will describe below, citing the sources I used.
I have read other sources, but I could not figure out what to do.
As I understand, most of these other sources assume I have some other server or address I can use (typically exemplified as example.com
), which I don't have, and I guess I can dispense with.
I followed this basic guide, which seemed to be useful for many others. After issuing
echo "Test mail thingy" | mail -s "Test Postfix Subject" mygmaildest@gmail.com
I did not get an email in
mygmaildest@gmail.com
, and this is the relevant tail of/var/log/mail.log
(line numbers added for reference)1 Apr 18 08:55:03 MyComputer postfix/postfix-script[1092678]: refreshing the Postfix mail system 2 Apr 18 08:55:03 MyComputer postfix/master[3124]: reload -- version 3.4.13, configuration /etc/postfix 3 Apr 18 08:55:24 MyComputer postfix/pickup[1092682]: 06004443921: uid=1000 from=<MyUser@MyComputer> 4 Apr 18 08:55:24 MyComputer postfix/cleanup[1092704]: 06004443921: message-id=<20210418115524.06004443921@MyComputer.MyISP_URL> 5 Apr 18 08:55:24 MyComputer postfix/qmgr[1092683]: 06004443921: from=<MyUser@MyComputer>, size=391, nrcpt=1 (queue active) 6 Apr 18 08:55:24 MyComputer postfix/error[1092706]: 06004443921: to=<mygmaildest@gmail.com>, relay=none, delay=0.03, delays=0.02/0/0/0.01, dsn=5.0.0, status=bounced ([smtp.gmail.com]:587) 7 Apr 18 08:55:24 MyComputer postfix/cleanup[1092704]: 09DD4443938: message-id=<20210418115524.09DD4443938@MyComputer.MyISP_URL> 8 Apr 18 08:55:24 MyComputer postfix/bounce[1092707]: 06004443921: sender non-delivery notification: 09DD4443938 9 Apr 18 08:55:24 MyComputer postfix/qmgr[1092683]: 09DD4443938: from=<>, size=2359, nrcpt=1 (queue active) 10 Apr 18 08:55:24 MyComputer postfix/qmgr[1092683]: 06004443921: removed 11 Apr 18 08:55:24 MyComputer postfix/local[1092708]: 09DD4443938: to=<MyUser@MyComputer>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox) 12 Apr 18 08:55:24 MyComputer postfix/qmgr[1092683]: 09DD4443938: removed
I don't know how to interpret this log. I note that line 11 states
status=sent
.I added
-a "From: username@gmail.com"
(ref). I did not get the mail either. Lines in/var/log/mail.log
that changed as compared to above are marked with*
. Now I havestatus=bounced
in line 11.3*Apr 18 09:54:43 MyComputer postfix/pickup[1098199]: 0353244348F: uid=1000 from=<mygmailsrc@gmail.com> <-- CHANGED 4 Apr 18 09:54:43 MyComputer postfix/cleanup[1098387]: 0353244348F: message-id=<20210418125443.0353244348F@MyComputer.MyISP_URL> 5*Apr 18 09:54:43 MyComputer postfix/qmgr[1098200]: 0353244348F: from=<mygmailsrc@gmail.com>, size=384, nrcpt=1 (queue active) <-- CHANGED 6 Apr 18 09:54:43 MyComputer postfix/error[1098389]: 0353244348F: to=<mygmaildest@gmail.com>, relay=none, delay=0.03, delays=0.02/0/0/0, dsn=5.0.0, status=bounced ([smtp.gmail.com]:587) 7 Apr 18 09:54:43 MyComputer postfix/cleanup[1098387]: 06E2F4436C3: message-id=<20210418125443.06E2F4436C3@MyComputer.MyISP_URL> 8 Apr 18 09:54:43 MyComputer postfix/bounce[1098390]: 0353244348F: sender non-delivery notification: 06E2F4436C3 9 Apr 18 09:54:43 MyComputer postfix/qmgr[1098200]: 06E2F4436C3: from=<>, size=2364, nrcpt=1 (queue active) 10 Apr 18 09:54:43 MyComputer postfix/qmgr[1098200]: 0353244348F: removed 11*Apr 18 09:54:43 MyComputer postfix/error[1098389]: 06E2F4436C3: to=<mygmailsrc@gmail.com>, relay=none, delay=0.01, delays=0/0/0/0, dsn=5.0.0, status=bounced ([smtp.gmail.com]:587) <-- CHANGED 12 Apr 18 09:54:43 MyComputer postfix/qmgr[1098200]: 06E2F4436C3: removed
Notes:
Prior to my attempts today, I already had postfix installed. I do not recall when and why I installed it. I do not recall either going through the postfix configuration screen. I know I can do it with
sudo dpkg-reconfigure postfix
, but I don't know which is the proper option.This adds
smtp_tls_CAfile = /etc/postfix/cacert.pem
to/etc/postfix/main.cf
, instead ofsmtp_tls_CApath ...
, and latercat
s a specific.pem
tocacert.pem
. I don't havecacert.pem
. I guess both options can work if properly configured.I have lots of soft links in
/etc/ssl/certs/
. I am not sure I need to add anything.I used my actual source gmail and corresponding password in
/etc/postfix/sasl_passwd
.
Related:
- How can I configure postfix to send emails via gmail (2FA problems)?
- SETUP for sending Mail via postfix to GMAIL
to use
ssmtp
instead ofpostfix
. - Setting gmail as default for sending files via email using gnome-gmail or desktop-webmail.
- https://rtcamp.com/tutorials/linux/ubuntu-postfix-gmail-smtp/
- Sending email from Gmail account to local Ubuntu server
- Ubuntu 20.04 Mail Setup Setting the Default From Address
- https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-18-04
- https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-on-ubuntu-20-04
- https://www.linuxbabe.com/mail-server/setup-basic-postfix-mail-sever-ubuntu
- https://www.cyberciti.biz/faq/how-to-configure-postfix-relayhost-smarthost-to-send-email-using-an-external-smptd/
- https://ubuntu.com/server/docs/mail-postfix
- https://devops.ionos.com/tutorials/configure-a-postfix-relay-through-gmail-on-ubuntu/
msmtp
. It is easy to set up. It only allows sending mail, no receiving.postfix
is a more complex send and receive solution you don't need. – user68186 Apr 18 '21 at 13:29nullmailer
it's orders of magnitude easier to set up than postfix. – Organic Marble Apr 18 '21 at 13:36msmtp
. But I meant to work withpostfix
, as I guess in the (near) future I will want to receive email also. – sancho.s ReinstateMonicaCellio Apr 18 '21 at 13:37nullmailer
. Can it also receive email? I guess in the (near) future I will want to receive email also. – sancho.s ReinstateMonicaCellio Apr 18 '21 at 13:38nullmailer
? Being inexperienced, I have no preference, other than the stated possibility of needing to receive emails in the future. – sancho.s ReinstateMonicaCellio Apr 18 '21 at 13:59relayhost = smtp.gmail.com:587
andrelay_domains = gmail.com
. You'll also have to go through the pain of setting up TLS and SASL to authorize to your gmail account. See the docs in /usr/share/doc/postfix/TLS_README.gz for additional help. – heynnema Apr 18 '21 at 14:18sancho@sreinstatemonicacellio.com
and don't want that address forward to Gmail, but reach your computer directly, then you you don't needpostfix
. – user68186 Apr 18 '21 at 14:26postfix
for my needs. Two questions follow then:sancho@sreinstatemonicacellio.com
(comment by @user68186) then I don't need that, as mentioned in the OP.I am not aware of the pains you cite. If you know of any guide, that would be great. I thought the links I read and posted would be enough (which were not, or were misinterpreted). In addition, two questions follow then:
sudo dpkg-reconfigure postfix
it's one of the first questions that it asks. Have you by chance checked out the docs at /usr/share/doc/postfix/? There's a ton there. I know that I had to spend a lot of time setting upPostfix
, and I personally only cared about being able to send emails. – heynnema Apr 18 '21 at 15:05nullmailer
andmsmtp
. 2. I usemsmtp
to send emails using bash script and cron. I don't think the automatic capability is any less or more thanpostscript
. – user68186 Apr 18 '21 at 16:38