0

I'm trying to configure POSTFIX to send emails via smtp.gmail.com, without any success. Iv'e tried following these two tutorials:
https://www.endpoint.com/blog/2019/04/30/postfix-gmail-forwarder https://www.linode.com/docs/guides/configure-postfix-to-send-mail-using-gmail-and-google-apps-on-debian-or-ubuntu/
None of the tutorials worked, never mind what I do I get a bounced message in the log. Also It seems that when I'm sending an Email via sendmail my from address is overwritten with "root@observium-pi".

Also:I know that in principle it works because I have an OpenHAB smtp connector that sends successfully emails using the same SMTP.

Here is my main.cf:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

Debian specific: Specifying a file name will cause the first

line of that file to be used as the name. The Debian default

is /etc/mailname.

#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Raspbian) biff = no

appending .domain is the MUA's job.

append_dot_mydomain = no

Uncomment the next line to generate "delayed mail" warnings

#delay_warning_time = 4h

readme_directory = no

See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on

fresh installs.

compatibility_level = 2

TLS parameters

smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for

information on enabling SSL in the smtp client.

#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = observium-pi alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = $myhostname, observium-pi, localhost.localdomain, localhost relayhost = [smtp.gmail.com]:465 mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = loopback-only default_transport = error relay_transport = error inet_protocols = all smtp_tls_wrappermode = yes smtp_tls_security_level = verify smtp_tls_mandatory_protocols = !SSLv2, !TLSv1, !TLSv1.1 tls_high_cipherlist = ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256 smtp_tls_mandatory_ciphers = high smtp_tls_loglevel = 2

smtp_sasl_auth_enable = yes smtp_sasl_mechanism_filter = plain smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth smtp_sasl_security_options = noanonymous

header_checks = regexp:/etc/postfix/header_checks You have new mail in /var/mail/root

Here is my smtp_auth (obfuscated), I'm using application specific password:

[smtp.gmail.com]:465 s******v@gmail.com:****************

and here is the log:

Jan 20 17:53:48 observium-pi postfix/pickup[13165]: 49AC73F2D5: uid=0 from=<root@observium-pi>
Jan 20 17:53:48 observium-pi postfix/cleanup[13725]: 49AC73F2D5: message-id=<20210120155348.49AC73F2D5@observium-pi>
Jan 20 17:53:48 observium-pi postfix/qmgr[13166]: 49AC73F2D5: from=<root@observium-pi>, size=354, nrcpt=1 (queue active)
Jan 20 17:53:48 observium-pi postfix/error[13727]: 49AC73F2D5: to=<s******v@gmail.com>, relay=none, delay=0.23, delays=0.13/0.04/0/0.06, dsn=5.0.0, status=bounced ([smtp.gmail.com]:465)
Jan 20 17:53:48 observium-pi postfix/cleanup[13725]: 728643F2D6: message-id=<20210120155348.728643F2D6@observium-pi>
Jan 20 17:53:48 observium-pi postfix/qmgr[13166]: 728643F2D6: from=<>, size=2169, nrcpt=1 (queue active)
Jan 20 17:53:48 observium-pi postfix/bounce[13728]: 49AC73F2D5: sender non-delivery notification: 728643F2D6
Jan 20 17:53:48 observium-pi postfix/qmgr[13166]: 49AC73F2D5: removed
Jan 20 17:53:49 observium-pi postfix/local[13729]: 728643F2D6: to=<root@observium-pi>, relay=local, delay=0.95, delays=0.02/0.05/0/0.88, dsn=2.0.0, status=sent (delivered to mailbox)
Jan 20 17:53:49 observium-pi postfix/qmgr[13166]: 728643F2D6: removed

Edit:

Contents of the bounce email:
From MAILER-DAEMON  Wed Jan 20 17:51:19 2021
Return-Path: <>
X-Original-To: root@observium-pi
Delivered-To: root@observium-pi
Received: by observium-pi (Postfix)
    id ECBA13F2D6; Wed, 20 Jan 2021 17:51:18 +0200 (IST)
Date: Wed, 20 Jan 2021 17:51:18 +0200 (IST)
From: MAILER-DAEMON@observium-pi (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: root@observium-pi
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
    boundary="2FE3A3F2D5.1611157878/observium-pi"
Content-Transfer-Encoding: 8bit
Message-Id: <20210120155118.ECBA13F2D6@observium-pi>
Status: O
X-UID: 17

This is a MIME-encapsulated message.

--2FE3A3F2D5.1611157878/observium-pi Content-Description: Notification Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit

This is the mail system at host observium-pi.

I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can delete your own text from the attached returned message.

               The mail system

<shaul@s******v.com>: [smtp.gmail.com]:465

--2FE3A3F2D5.1611157878/observium-pi Content-Description: Delivery report Content-Type: message/delivery-status

Reporting-MTA: dns; observium-pi X-Postfix-Queue-ID: 2FE3A3F2D5 X-Postfix-Sender: rfc822; root@observium-pi Arrival-Date: Wed, 20 Jan 2021 17:50:47 +0200 (IST)

Final-Recipient: rfc822; shaul@s****v.com Original-Recipient: rfc822;shaul@s****v.com Action: failed Status: 5.0.0 Diagnostic-Code: X-Postfix; [smtp.gmail.com]:465

--2FE3A3F2D5.1611157878/observium-pi Content-Description: Undelivered Message Content-Type: message/rfc822 Content-Transfer-Encoding: 8bit

Return-Path: <root@observium-pi> Received: by observium-pi (Postfix, from userid 0) id 2FE3A3F2D5; Wed, 20 Jan 2021 17:51:16 +0200 (IST) from: s******v@gmail.com subject: quick email Message-Id: <20210120155117.2FE3A3F2D5@observium-pi> Date: Wed, 20 Jan 2021 17:50:47 +0200 (IST)

sending a quick email

--2FE3A3F2D5.1611157878/observium-pi--

0 Answers0