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

Fixes bug where emails are sent to blocked addresses #43

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

gseph
Copy link
Contributor

@gseph gseph commented Nov 20, 2023

As per title, this PR fixes a bug introduced by the adoption of Laravel 9.x which uses symfony/mime since Laravel 7.x.

Blocked email addresses would not be filtered out when sending emails.

Environment info

  • PHP 8.2
  • WinterCMS 1.2.3 (I'm assuming the bug got introduced since version 1.2.0 since it requires Laravel 9.x)

Steps to reproduce the bug

  • Create and set up a WinterCMS project.
  • Add the user plugin.
  • From backend, manually create and activate two users.
  • Edit the first one by checking the checkbox to block all emails towards that user.
  • Set up a mail server. I'm using MailHog with docker, here's the docker-compose.yaml file I've used.
version: '3.5'

services:
  db:
    image: mysql:8.0.33-debian
    container_name: "db"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_DATABASE: ${DB_DATABASE}
      DB_USER: ${DB_USERNAME}
      DB_PASSWORD: ${DB_PASSWORD}
    volumes:
      - "./docker-volumes/mysql-data:/var/lib/mysql"
    ports:
      - "${DB_PORT}:3306"
  mailhog:
    image: mailhog/mailhog
    container_name: 'mailhog'
    ports:
      - "1025:1025"
      - "8025:8025"
  • Email the blocked user. Easily done it from the artisan tinker.
\Mail::raw('test body', function($m) {$m->to(['[email protected]'])->subject('test subject');})

You'll notice that the email gets sent to the blocked email address.

Also, email addresses in the cc and bcc fields were never going to be filtered out since the method MailBlocker::filterMessage only ever tried to filter out the main recipients.

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

Successfully merging this pull request may close these issues.

None yet

2 participants