MasoniteFramework / masonite

The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Discord channel for questions: https://discord.gg/TwKeFahmPZ
http://docs.masoniteproject.com
MIT License
2.22k stars 126 forks source link

'route' undefined when sending emails with templates from jobs #648

Closed dwedigital closed 2 years ago

dwedigital commented 2 years ago

Describe the bug

I am wanting to use a job to send a mailable. This mailable uses a template for the content.

When I run the queue worke the jobs fail with the following: 'route' is undefined

Job:

from masonite.queues import Queueable
from app.mailables.NewChallenge import NewChallenge
from masonite.facades import Mail

class SendNewChallengeEmail(Queueable):
    def __init__(self, wager) -> None:
        self.wager = wager
        print(self.wager.challenger)
    def handle(self):
        Mail.mailable(NewChallenge(self.wager).to(self.wager.challenger)).send()

Mailable:

from masonite.configuration import config
from masonite.mail import Mailable

from app.models.Wager import Wager

class NewChallenge(Mailable):
    def __init__(self, wager: Wager):
        super().__init__()
        self.wager = wager

    def build(self):
        return (
            self.subject("You've Been Challenged to a Wager")
            .from_(config("mail.from_address"))
            .view("wager.mailables.newwagerchallenger", {"wager": self.wager})
        )

Expected behaviour

No response

Steps to reproduce the bug

No response

Screenshots

No response

OS

macOS

OS version

Monteray

Browser

No response

Masonite Version

4.14.0

Anything else ?

No response

dwedigital commented 2 years ago

Hey @josephmancuso since this fix mails are now not sending (even if sent without queuing i.e. mail.mailable(NewChallenge(wager).to(wager.challenger)).send())

The jobs stop failing and they complete but noticed the emails were not being delivered. Checked Mailgun and there is no activity in the logs either. Then reverted to using the straight mail.mailable() approach in the controller that was working previously and nothing in Mailgun logs or inbox (spam, other etc.)

girardinsamuel commented 2 years ago

Hey @josephmancuso since this fix mails are now not sending (even if sent without queuing i.e. mail.mailable(NewChallenge(wager).to(wager.challenger)).send())

The jobs stop failing and they complete but noticed the emails were not being delivered. Checked Mailgun and there is no activity in the logs either. Then reverted to using the straight mail.mailable() approach in the controller that was working previously and nothing in Mailgun logs or inbox (spam, other etc.)

Just to keep track: this issue is being discussed on Discord #questions channel. We will open an issue if we manage to reproduce this.