Configuring postfix to relay via google or somewhere else

ha ha ha…

now it’s saying bad authentication, implying username/password is wrong… i just copy pasted it from where i used it to log onto the web site.

can nothing ever work.

G

you need to use the apikey as the username and the key as the password

used api key id as username and the key as pw, still same Bad username/pw message.

have to pop out for 90min.

G

ok… so sorry for this very sarcastic comment now…

ok. so you go onto your google account, go security, enable 2FA auth.
Once that is done it then presents you with a App Password option.
Select, then Select Generate. select mail from first drop down, then Select Other from the 2nd drop down, give your app a name and click Generate, it will now generate a 16 digit password.
Go back to your app, and change your current password for this 16 digit password and bobs your uncle… all keeps working on port 25 without TLS or StartTLS or anything else.

ha ha ha… got to laugh.

Still going to see and try my hand at getting a email server set up to send out via, for sh$t and giggles. and maybe get that email relay working with google on the other side, as it seems even they would want this new password…

G

I also used to use my gmail account with postfix. Eventually it stopped working, I gave up and moved on to sendgrid. Basically a free account, your from address can be anything for a domain you own after a ticket with them and now I have zero issues with mail delivery. I use a free account with them.

My docker-compose config looks like this:

  postfix:
    container_name: postfix
    image: boky/postfix
    restart: always
    environment:
      - RELAYHOST=[smtp.sendgrid.net]:587
      - RELAYHOST_USERNAME=${MAILUSER}
      - RELAYHOST_PASSWORD=${MAILPASS}
      - ALLOW_EMPTY_SENDER_DOMAINS=true
      - POSTFIX_mynetworks=127.0.0.0/8 10.0.0.0/8 172.0.0.0/8 192.168.0.0/16
      - POSTFIX_smtpd_client_restrictions=permit_mynetworks
      - POSTFIX_smtp_use_tls=yes
      - POSTFIX_smtp_sasl_security_options=noanonymous
      - POSTFIX_smtp_tls_security_level=encrypt
      - POSTFIX_smtp_tls_security_level=verify
      - POSTFIX_smtp_tls_loglevel=1
    ports:
      - "587:587"
    labels:
      - com.centurylinklabs.watchtower.enable=true
1 Like

thanks,

so i got google working again, see my previous posting above detailing how to.
thanks for the above,
for :
- RELAYHOST_USERNAME=${MAILUSER}
- RELAYHOST_PASSWORD=${MAILPASS}
what do you enter here, the sendgrid user account email address and password ?
found a document that details how to configure the main.cf if using sendgrid.
most of my emails I want a from address of ...@gmail.com to simplify the reply if ever… (ps happens to be that my to addresses are all ...@gmail.com but guess if the email goes to sendgrid with their smtp should not matter. for now i guess need to decide what i want to do.
firstly jsut sending out notifications, well with gmail resolved now that all works, but guess i want to build up a plan B so long, and then won’t mind setting up a email server myself that can send and receive. aka send to my own domain and receive at my domain.

G

MAILUSER=apikey
MAILPASS= {actual api key}

Mine starts with SG.Cj7 and is one long ass key. 70 chars I think.

Sendgrid is only for sending, for receiving you have to either get something that holds the emails or have the MX record point back to where you hosting a mailserver.

The postfix above in docker I use only for sending out from my local lan. Have a printer that needs one as an example, that email scanned documents as pdf to me.
Proxmox and things like that also need to notify me if hard drives will fail etc.

ye, sendmail is basically just a nice smtp service. you using the straight api key ir the openssl converted into base64 converted version.

I can create a MX record, my domain sits with cloudflare,

ye, sort of same use case, got various bit that need to send take note of XYZ. for now got gmail working again, figured out how to make them work using normal old port 25. but thinking might be good idea to come up with a long term plan b.

and then ye playing with idea to just setup my own mail server, to go with the move MX record.

G