Page 1 of 1

"Nur empfangen" Mailaccount

Posted: Tue 3. Sep 2024, 14:14
by xeppel
hallo,

ich habe eine spezielle Domain reserviert von der ich nur erlauben möchte, dass eingehende Mails an eine andere weitergeleitet werden. Der Nutzer soll nicht von dieser Emailadresse bzw. Domain senden können. Gibts da von KH aus eine Möglichkeit das umzusetzen ?

Re: "Nur senden" Mailaccount

Posted: Tue 3. Sep 2024, 14:28
by Jolinar
Das Thema hatten wir erst...
viewtopic.php?t=13415

Re: "Nur empfangen" Mailaccount

Posted: Tue 3. Sep 2024, 14:41
by xeppel
Ups falscher Titel, ich meine nur Empfangen, nicht senden :D Aber das mit smtpd_sender_restrictions werde ich mal versuchen.

Re: "Nur empfangen" Mailaccount

Posted: Tue 3. Sep 2024, 17:30
by Fezzi
Du koenntest ja die entsprechenden Postausgangs Ports per Firewall sperren... 8-)

Klappt aber auch nur wenn sonst keine andren Accounts auf dem Server sind.. :lol:

Re: "Nur empfangen" Mailaccount

Posted: Tue 3. Sep 2024, 17:58
by Henning
Oder Neukunde bei Hetzner oder Strato werden, da sind die von Haus aus erstmal gesperrt! :lol:

Re: "Nur empfangen" Mailaccount

Posted: Tue 3. Sep 2024, 20:36
by xeppel
Also ich habe die Domain jetzt "@domain.tld REJECT" in die /etc/postfix/restricted_senders eingetragen, per postmap die Datei umgewandelt und die main.cf angepasst, postfix neu gestartet aber ich kann immer noch Mails senden :/

Warum ?

Re: "Nur empfangen" Mailaccount

Posted: Tue 3. Sep 2024, 21:10
by Henning
Wenn ich das richtig verstanden habe, müssen es reelle E-Mail-Adressen sein, Domains sind nicht zulässig.

https://www.postfix.org/postconf.5.html ... strictions

Ansonsten bin ich bei dem Thema auch raus, da ich diesen Fall so nicht habe.

Re: "Nur empfangen" Mailaccount

Posted: Wed 4. Sep 2024, 03:13
by Fezzi
Warum nicht die KI fragen... das waere schon mal ein erster Ansatz....
In Postfix, you can restrict an email address or user from sending emails by using access control mechanisms in the Postfix configuration. Here's how you can set it up:

### 1. Use `smtpd_sender_restrictions`

Postfix allows you to define rules to control which senders are allowed or denied. To restrict sending emails for a specific address, you can use the `smtpd_sender_restrictions` parameter in the Postfix configuration.

#### Steps:

1. **Edit the Postfix Main Configuration File:**
Open the Postfix main configuration file, usually located at `/etc/postfix/main.cf`, with a text editor of your choice:

```sh
sudo nano /etc/postfix/main.cf
```

2. **Add or Modify `smtpd_sender_restrictions`:**
Add or update the `smtpd_sender_restrictions` parameter to include a reference to a new file where you will specify the restrictions. For example:

```plaintext
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access
```

3. **Create or Edit the `sender_access` File:**
Create or edit the file specified in the `smtpd_sender_restrictions` parameter, which in this case is `/etc/postfix/sender_access`:

```sh
sudo nano /etc/postfix/sender_access
```

4. **Add Restriction Rules:**
Add a rule to block sending for the specific email address. For example, to block `user@example.com`:

```plaintext
user@example.com REJECT
```

5. **Update Postfix with the New Access File:**
After modifying the `sender_access` file, you need to hash the file and reload Postfix:

```sh
sudo postmap /etc/postfix/sender_access
sudo systemctl reload postfix
```

### 2. Using `smtpd_recipient_restrictions`

Alternatively, you can use `smtpd_recipient_restrictions` to block specific senders if your setup uses that parameter.

#### Steps:

1. **Edit the Postfix Main Configuration File:**
Open the Postfix main configuration file:

```sh
sudo nano /etc/postfix/main.cf
```

2. **Add or Modify `smtpd_recipient_restrictions`:**
Add or update the `smtpd_recipient_restrictions` parameter:

```plaintext
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access
```

3. **Create or Edit the `recipient_access` File:**
Create or edit the file specified in the `smtpd_recipient_restrictions` parameter:

```sh
sudo nano /etc/postfix/recipient_access
```

4. **Add Restriction Rules:**
Add a rule to block sending for the specific email address:

```plaintext
user@example.com REJECT
```

5. **Update Postfix with the New Access File:**
Hash the file and reload Postfix:

```sh
sudo postmap /etc/postfix/recipient_access
sudo systemctl reload postfix
```

### Summary

By using either `smtpd_sender_restrictions` or `smtpd_recipient_restrictions`, you can effectively block a specific email address from sending messages. Ensure you adjust your configuration based on whether you want to block sending globally or for specific users. Always reload Postfix after making changes to ensure that your new settings take effect.

Re: "Nur empfangen" Mailaccount

Posted: Wed 4. Sep 2024, 10:19
by xeppel
Fezzi wrote: Wed 4. Sep 2024, 03:13 Warum nicht die KI fragen... das waere schon mal ein erster Ansatz....
hab ich ja, und das waren ja die Schritte...

Re: "Nur empfangen" Mailaccount

Posted: Wed 4. Sep 2024, 12:51
by xeppel
Henning wrote: Tue 3. Sep 2024, 21:10Wenn ich das richtig verstanden habe, müssen es reelle E-Mail-Adressen sein, Domains sind nicht zulässig.
Hab es auch mit alias@domain.tld versucht. laut dem Beitrag sollten auch Domains gehen, aber scheinbar gehts über PHP dann dennoch, habs über roundcube getestet: https://serverfault.com/questions/46372 ... lar-domain

Re: "Nur empfangen" Mailaccount

Posted: Wed 4. Sep 2024, 14:33
by omexlu
xeppel wrote: Wed 4. Sep 2024, 12:51
Henning wrote: Tue 3. Sep 2024, 21:10Wenn ich das richtig verstanden habe, müssen es reelle E-Mail-Adressen sein, Domains sind nicht zulässig.
Hab es auch mit alias@domain.tld versucht. laut dem Beitrag sollten auch Domains gehen, aber scheinbar gehts über PHP dann dennoch, habs über roundcube getestet: https://serverfault.com/questions/46372 ... lar-domain
Für PHP muss du in den PHP-Einstellungen " disable_functions = mail " erweitern / hinzufügen.

Re: "Nur empfangen" Mailaccount

Posted: Thu 12. Sep 2024, 14:14
by xeppel
Habe ich gemacht, geht trotzdem weiterhin.

Re: "Nur empfangen" Mailaccount

Posted: Thu 12. Sep 2024, 14:38
by omexlu
Das ist nur dass keine Mails mehr über PHP versendet werden (was ich gepostet habe).