Server script Helpdesk

i’m trying to do a validation in the frappe helpdesk.
I want it to validate all tickets with open and replied status and send an e-mail to the owner of that ticket if this condition is true. I made a code that doesn’t show any errors, but the e-mail doesn’t go to the queue and isn’t sent.

Test sending the e-mail separately and it works.

Here’s my code:

Can you help me?

server script type: Scheduler event


def execute():
    
    tickets = frappe.get_all(
        "HD Ticket",
        filters={
            "status": ["in", ["Open", "Replied"]],
        },
        fields=["name", "raised_by", "subject", "status"],
        limit_page_length=None 
    )

    if not tickets:
        return

    for t in tickets:
       '.
        frappe.sendmail(
            recipients=[t.raised_by],
        
            subject=f"Teste: {t.name}",
            message=f"""
                <p>Hello,</p>
                <p>e-mail body <b>{t.subject}</b> >
            """,
            now=True 
        )

tickets = frappe.get_all(
    "HD Ticket",
    filters={"status": ["in", ["Open", "Replied"]]},
    fields=["name", "subject", "raised_by"]
)

for ticket in tickets:
    if ticket.raised_by:
        frappe.sendmail(
            recipients=[ticket.raised_by],
            subject=f"HD Ticket: {ticket.subject}",
            message=f"body."
        )