Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postfix losing connection #829

Open
LaleeshAM opened this issue May 19, 2024 · 2 comments
Open

Postfix losing connection #829

LaleeshAM opened this issue May 19, 2024 · 2 comments

Comments

@LaleeshAM
Copy link

LaleeshAM commented May 19, 2024

I have a PHP mailer script that works with local host, but when I try to submit a form via server with postfix installed, it doesn't work due to multiple disconnections.
Let me know if you need more information, I'll be glad to share.

image

My configuration:

# 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 (Ubuntu)
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 3.6 on
# fresh installs.
compatibility_level = 3.6



# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

smtp_tls_CApath=/etc/ssl/certs
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = Laleesh
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, laleesh.com, Laleesh, localhost.localdomain, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

@DavidGoodwin
Copy link
Member

Hi -

This isn't a general postfix help forum. Postfixadmin is a web interface for managing mailboxes/aliases/domains that integrates with Postfix. Your question will probably be answered better elsewhere (e.g stackoverflow).

Having said that ....

Assuming your problem is the disconnect from 152.32.227.252 then ... unless your script is doing SMTP + auth, it isn't going to get far.

Your postfix config above will tell the server to accept mail from localhost without question, but not from anywhere else. Which probably explains why your script worked locally.

To fix this either, add the 152.... IP into mynetworks in postfix's main.cf and restart postfix - but only do that if you absolutely trust that server.

If you don't trust the 152... IP (or the server's IP isn't static) then you need to make sure your script is doing SMTP+Auth -

e.g if your script was written in PHP AND using SwiftMailer ... you might have something along the lines of this in it :

$transport = new Swift_SmtpTransport("your.mail.server", "25"); // note: plain text, should move to tls etc
$transport->setUsername('something');
$transport->setPassword('password');
$mailer = new Swift_Mailer($transport);
$message = new Swift_Message('some subject');
$message->setBody('test');
$message->setFrom('me@example.com');
$message->setTo('my.recipient@example.com');

$mailer->send($message);

This may also require significant changes to your postfix server's configuration - so it would know where to lookup users (which is where Postfixadmin could fit in). You might find it easiest however just using the system passwd file etc - see also https://www.postfix.org/VIRTUAL_README.html#local

@LaleeshAM
Copy link
Author

My bad, sorry.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants