Can't send email with Mautic 5.1.1

Your software
My Mautic version is: 5.1.1
My PHP version is: 8.2.22
My Database type and version is: mySql 5.7.23-23

Your problem
My problem is:
Mautic does not send any emails, neither test nor campaign emails.
But when I click on test, it returns a message that it has been sent.

These errors are showing in the log:
No errors in erro_log or var/logs files.

Steps I have tried to fix the problem:

  • Enable Debug=true;

  • Clear the cache: php bin/console cache:clear -v;

  • Force send messages: php bin/console mautic:messages:send
    Processing message queue
    Messages sent: 0

  • Test the smtp server with python script, and work:
    import smtplib
    from email.mime.text import MIMEText

    smtp_server = “mail.networkemlisboa.com”
    smtp_port = 465
    smtp_user = “contato@networkemlisboa.com”
    smtp_password =

    msg = MIMEText(“Test mail server”)
    msg[“Subject”] = “Test mail server”
    msg[“From”] = smtp_user
    msg[“To”] = “noi.juliano@gmail.com”

    try:
    with smtplib.SMTP_SSL(smtp_server, smtp_port) as server:
    server.login(smtp_user, smtp_password)
    server.sendmail(smtp_user, [“noi.juliano@gmail.com”], msg.as_string())
    print(“E-mail send Ok!”)
    except Exception as e:
    print(f"Error send e-mail: {e}")

You need to configure a queue and the transport that is most common one and easier to configure is doctrine.
Mautic changed from 4 to 5. In 4, emails were created as files and saved in the /var/queue folder (if I recall correctly), now emails are saved in a table (message_messages) and sent from there and the worker (the doctrine thing) is what actually send the emails in the queue that is in the db.

Here is a guide: Configuring Doctrine for Email Queue Management in Mautic with Cron Jobs - Mautic Knowledgebase

Have set this up, but it sends campaigns with many subscribers very slow @rcarabelli.
Do you have an idea, why?

Thanks in advance.

Georg

What do you mean by slow?

Hi @joeyk,

only a few mails are processed at the same time (5.1.1). It’s only faster if I bash the script manually on the server. But even not as fast as with message queue with 4.4.13.

Crazy.

Is this a segment send or a campaign?

A campaign.

Are you using queue?
If yes - is the queue creation too slow?
Or campaign generates the emails too slow?

Using the new doctrine.

Applied the scripts from @rcarabelli and modified your script for this.

is the queue creation too slow?
Or the emails disappearing slow from the queue?

Maybe just took the wrong path for php. :thinking:

Investigating.

The guide is to send 600 mails hour. If you want another speed let me know and can modify it for you

Hi @rcarabelli,

should be okay atm.
But it seems to send slower imho.

Investigating and tell it here then.

Thanks.

Thank you.
I tried the recommendation, but it didn’t work.

I restored a backup from version 4.4, and upgraded to 5.1.1.
The test email worked, but for now only the test is working and only sends to the owner.
I tested it in a Channel>Email, but it doesn’t send the test.
I believe it’s something related to the migration, I’m still investigating.
I was able to execute most of the SQL commands manually, but there was a DROP INDEX of an index that doesn’t exist, I don’t know how to solve it yet.

But thanks for the recommendation.

# bin/console doctrine:schema:update --dump-sql


 [WARNING] Not passing the "--complete" option to "doctrine:schema:update" is deprecated and will not be supported when
           using doctrine/dbal 4


DROP INDEX IDX_1AE3441319EB6921 ON oauth2_user_client_xref;
DROP INDEX IDX_6480052EF639F774 ON campaign_leadlist_xref;
DROP INDEX IDX_3048A8B2F639F774 ON campaign_form_xref;
DROP INDEX IDX_5995213DF639F774 ON campaign_leads;
DROP INDEX IDX_2E24F01CA832C1C9 ON email_list_xref;
DROP INDEX IDX_3D3C217BA832C1C9 ON email_list_excluded;
DROP INDEX IDX_CA315778A832C1C9 ON email_assets_xref;
DROP INDEX IDX_9EED7E6655458D ON lead_ips_xref;
DROP INDEX IDX_F2E51EB655458D ON lead_tags_xref;
DROP INDEX IDX_F5F47C7CB9FC8874 ON lead_lists_leads;
DROP INDEX IDX_F4190AB6979B1AD6 ON companies_leads;
DROP INDEX IDX_473919EFEF1A9D84 ON push_notification_list_xref;
DROP INDEX IDX_2F81A41DB42D874D ON channel_url_trackables;
DROP INDEX IDX_9D85A703E7A1254A ON point_group_contact_score;
DROP INDEX IDX_C2A3BDBA71F7E88B ON point_lead_event_log;
DROP INDEX IDX_6DF94A56C028CEA2 ON point_lead_action_log;
DROP INDEX IDX_B032FC2EBD5C7E60 ON sms_message_list_xref;
DROP INDEX IDX_A506AFBE2298D193 ON stage_lead_action_log;
DROP INDEX IDX_45207A4A4CE1C902 ON monitoring_leads;

# bin/console doctrine:migrations:migrate

 WARNING! You are about to execute a migration in database "vivia552_mautic" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > yes


 [WARNING] You have 49 previously executed migrations in the database that are not registered migrations.


 >> 2023-12-13 01:35:30 (20180508202930)
 >> 2023-12-13 01:35:30 (20180702014364)
 >> 2023-12-13 01:35:31 (20180702014365)
 >> 2023-12-13 01:35:32 (20180821144204)
 >> 2023-12-13 01:35:33 (20180921144421)
 >> 2023-12-13 01:35:34 (20181111095447)
 >> 2023-12-13 01:35:34 (20190704154940)
 >> 2023-12-13 01:35:37 (20190724110039)
 >> 2023-12-13 01:35:37 (20191017140848)
 >> 2023-12-13 01:35:38 (20191126093923)
 >> 2023-12-13 01:35:39 (20191206113956)
 >> 2023-12-13 01:35:40 (20191219155630)
 >> 2023-12-13 01:35:41 (20200211095409)
 >> 2023-12-13 01:35:42 (20200212141530)
 >> 2023-12-13 01:35:42 (20200220172041)
 >> 2023-12-13 01:35:42 (20200227110431)
 >> 2023-12-13 01:35:42 (20200302164801)
 >> 2023-12-13 01:35:42 (20200331160919)
 >> 2023-12-13 01:35:43 (20200409102100)
 >> 2023-12-13 01:35:43 (20200422144300)
 >> 2023-12-13 01:35:44 (20200507122854)
 >> 2023-12-13 01:35:45 (20200729170800)
 >> 2023-12-13 01:35:45 (20200805185714)
 >> 2023-12-13 01:35:46 (20200810153131)
 >> 2023-12-13 01:35:47 (20200812180900)
 >> 2023-12-13 01:35:47 (20200815153711)
 >> 2023-12-13 01:35:48 (20200924080139)
 >> 2023-12-13 01:35:48 (20201015084627)
 >> 2023-12-13 01:35:48 (20201102120710)
 >> 2023-12-13 01:35:48 (20201102133546)
 >> 2023-12-13 01:35:49 (20201105120328)
 >> 2023-12-13 01:35:49 (20201120122846)
 >> 2023-12-13 01:35:50 (20201123070813)
 >> 2023-12-13 01:35:50 (20201125155904)
 >> 2023-12-13 01:35:50 (20201130201631)
 >> 2023-12-13 01:35:50 (20201207114926)
 >> 2023-12-13 01:35:51 (20201207140911)
 >> 2023-12-13 01:35:51 (20201228041109)
 >> 2023-12-13 01:35:52 (20210104171005)
 >> 2023-12-13 01:35:52 (20210203143600)
 >> 2023-12-13 01:35:53 (20210223174702)
 >> 2023-12-13 01:35:53 (20210502162314)
 >> 2023-12-13 01:35:53 (20210520100503)
 >> 2023-12-13 01:35:55 (20210609191822)
 >> 2023-12-13 01:35:55 (20210614151138)
 >> 2023-12-13 01:35:55 (20210623071326)
 >> 2023-12-13 01:35:55 (20220111202917)
 >> 2023-12-13 01:35:55 (20230519081315)
 >> 2023-12-13 01:35:56 (20230522115137)

 Are you sure you wish to continue? (yes/no) [yes]:
 > yes

[notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[notice] Migration Mautic\Migrations\Version20201026101117 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20221128145933 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table plugin_citrix_events already exists
[notice] Migration Mautic\Migrations\Version20230522141144 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration is not required.
[notice] Migration Mautic\Migrations\Version20230606111852 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20230627140512 skipped during Pre-Checks. Reason: "The deprecated %kernel.root_dir% is unused. Your local.php file is just fine. Skipping the migration."
[notice] Migration Mautic\Migrations\Versionzz20230929183000 skipped during Pre-Checks. Reason: "There are no local config files to migrate. Skipping the migration."
[notice] finished in 521.9ms, used 56.5M memory, 6 migrations executed, 0 sql queries

Have to update the guide, upgraded the files. Will do it in like 5 hours and share them with you in here.

2 Likes

Hello,
I apologise for my lack of knowledge, but I have another question: Do you need to apply all these migrations, and if so, how should they be applied?

I followed the tutorial at this link: How to update Mautic — Mautic Documentation 0.1 documentation

Everything went smoothly up until the "mautic:update

–finish" step, but I’m uncertain which migrations are necessary.

The two features I’ve noticed aren’t working are:

  • Email sending in Channels > Emails, only sends emails to the owner.
  • Forms are also not functioning.
[~/mautic]# bin/console mautic:update:apply
Are you sure you wish to update Mautic to the latest version? yes
Step    1 [>---------------------------] Running pre-update checks...

One or more errors occurred while checking your environment prior to updating Mautic:
- Great! You are running the current version of Mautic.

[~/mautic]# bin/console mautic:update:apply --finish
Step    2 [============================] Success! You are now running version 5.1.1 of Mautic.

[~/mautic]# bin/console doctrine:schema:validate
Mapping
-------
 [FAIL] The entity-class Mautic\DynamicContentBundle\Entity\DynamicContentLeadData mapping is invalid:
 * The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which is not defined as association.
 * The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which does not exist.

Database
--------
 [ERROR] The database schema is not in sync with the current mapping file.


[~/mautic]#
[~/mautic]# bin/console doctrine:migrations:up-to-date
 [ERROR] Out-of-date! 6 migrations are available to execute.
 [ERROR] You have 49 previously executed migrations in the database that are not registered migrations.

[~/mautic]# bin/console doctrine:migrations:status
+----------------------+----------------------+------------------------------------------------------------------------+
| Configuration                                                                                                        |
+----------------------+----------------------+------------------------------------------------------------------------+
| Storage              | Type                 | Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration |
|                      | Table Name           | migrations                                                             |
|                      | Column Name          | version                                                                |
|----------------------------------------------------------------------------------------------------------------------|
| Database             | Driver               | Doctrine\DBAL\Driver\PDO\MySQL\Driver                                  |
|                      | Name                 | vivia552_mautic                                                        |
|----------------------------------------------------------------------------------------------------------------------|
| Versions             | Previous             | Mautic\Migrations\Version20240416112112                                |
|                      | Current              | Mautic\Migrations\Version20240708153845                                |
|                      | Next                 | Mautic\Migrations\Version20201026101117                                |
|                      | Latest               | Mautic\Migrations\Versionzz20230929183000                              |
|----------------------------------------------------------------------------------------------------------------------|
| Migrations           | Executed             | 85                                                                     |
|                      | Executed Unavailable | 49                                                                     |
|                      | Available            | 42                                                                     |
|                      | New                  | 6                                                                      |
|----------------------------------------------------------------------------------------------------------------------|
| Migration Namespaces | Mautic\Migrations    | /home2/vivia552/mautic/app/migrations                                  |
+----------------------+----------------------+------------------------------------------------------------------------+

[~/mautic]# bin/console doctrine:migrations:list
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+
| Migration Versions                                                                                         |             |
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+
| Migration                                 | Status                  | Migrated At         | Execution Time | Description |
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+
| 20180508202930                            | migrated, not available | 2023-12-13 01:35:30 |                |             |
| 20180702014364                            | migrated, not available | 2023-12-13 01:35:30 |                |             |
| 20180702014365                            | migrated, not available | 2023-12-13 01:35:31 |                |             |
| 20180821144204                            | migrated, not available | 2023-12-13 01:35:32 |                |             |
| 20180921144421                            | migrated, not available | 2023-12-13 01:35:33 |                |             |
| 20181111095447                            | migrated, not available | 2023-12-13 01:35:34 |                |             |
| 20190704154940                            | migrated, not available | 2023-12-13 01:35:34 |                |             |
| 20190724110039                            | migrated, not available | 2023-12-13 01:35:37 |                |             |
| 20191017140848                            | migrated, not available | 2023-12-13 01:35:37 |                |             |
| 20191126093923                            | migrated, not available | 2023-12-13 01:35:38 |                |             |
| 20191206113956                            | migrated, not available | 2023-12-13 01:35:39 |                |             |
| 20191219155630                            | migrated, not available | 2023-12-13 01:35:40 |                |             |
| 20200211095409                            | migrated, not available | 2023-12-13 01:35:41 |                |             |
| 20200212141530                            | migrated, not available | 2023-12-13 01:35:42 |                |             |
| 20200220172041                            | migrated, not available | 2023-12-13 01:35:42 |                |             |
| 20200227110431                            | migrated, not available | 2023-12-13 01:35:42 |                |             |
| 20200302164801                            | migrated, not available | 2023-12-13 01:35:42 |                |             |
| 20200331160919                            | migrated, not available | 2023-12-13 01:35:42 |                |             |
| 20200409102100                            | migrated, not available | 2023-12-13 01:35:43 |                |             |
| 20200422144300                            | migrated, not available | 2023-12-13 01:35:43 |                |             |
| 20200507122854                            | migrated, not available | 2023-12-13 01:35:44 |                |             |
| 20200729170800                            | migrated, not available | 2023-12-13 01:35:45 |                |             |
| 20200805185714                            | migrated, not available | 2023-12-13 01:35:45 |                |             |
| 20200810153131                            | migrated, not available | 2023-12-13 01:35:46 |                |             |
| 20200812180900                            | migrated, not available | 2023-12-13 01:35:47 |                |             |
| 20200815153711                            | migrated, not available | 2023-12-13 01:35:47 |                |             |
| 20200924080139                            | migrated, not available | 2023-12-13 01:35:48 |                |             |
| 20201015084627                            | migrated, not available | 2023-12-13 01:35:48 |                |             |
| 20201102120710                            | migrated, not available | 2023-12-13 01:35:48 |                |             |
| 20201102133546                            | migrated, not available | 2023-12-13 01:35:48 |                |             |
| 20201105120328                            | migrated, not available | 2023-12-13 01:35:49 |                |             |
| 20201120122846                            | migrated, not available | 2023-12-13 01:35:49 |                |             |
| 20201123070813                            | migrated, not available | 2023-12-13 01:35:50 |                |             |
| 20201125155904                            | migrated, not available | 2023-12-13 01:35:50 |                |             |
| 20201130201631                            | migrated, not available | 2023-12-13 01:35:50 |                |             |
| 20201207114926                            | migrated, not available | 2023-12-13 01:35:50 |                |             |
| 20201207140911                            | migrated, not available | 2023-12-13 01:35:51 |                |             |
| 20201228041109                            | migrated, not available | 2023-12-13 01:35:51 |                |             |
| 20210104171005                            | migrated, not available | 2023-12-13 01:35:52 |                |             |
| 20210203143600                            | migrated, not available | 2023-12-13 01:35:52 |                |             |
| 20210223174702                            | migrated, not available | 2023-12-13 01:35:53 |                |             |
| 20210502162314                            | migrated, not available | 2023-12-13 01:35:53 |                |             |
| 20210520100503                            | migrated, not available | 2023-12-13 01:35:53 |                |             |
| 20210609191822                            | migrated, not available | 2023-12-13 01:35:55 |                |             |
| 20210614151138                            | migrated, not available | 2023-12-13 01:35:55 |                |             |
| 20210623071326                            | migrated, not available | 2023-12-13 01:35:55 |                |             |
| 20220111202917                            | migrated, not available | 2023-12-13 01:35:55 |                |             |
| 20230519081315                            | migrated, not available | 2023-12-13 01:35:55 |                |             |
| 20230522115137                            | migrated, not available | 2023-12-13 01:35:56 |                |             |
| Mautic\Migrations\Version020230615115326  | migrated                | 2024-10-25 14:49:38 | 1.392s         |             |
| Mautic\Migrations\Version20190326190241   | migrated                | 2024-10-25 14:49:40 | 0.345s         |             |
| Mautic\Migrations\Version20190410143658   | migrated                | 2024-10-25 14:49:40 | 0.288s         |             |
| Mautic\Migrations\Version20190524124819   | migrated                | 2024-10-25 14:49:40 | 0.31s          |             |
| Mautic\Migrations\Version20191106152509   | migrated                | 2024-10-25 14:49:41 | 0.001s         |             |
| Mautic\Migrations\Version20200415135706   | migrated                | 2024-10-25 14:49:41 | 0.33s          |             |
| Mautic\Migrations\Version20200513162918   | migrated                | 2024-10-25 14:49:41 | 0.441s         |             |
| Mautic\Migrations\Version20200917152259   | migrated                | 2024-10-25 14:49:41 | 0.264s         |             |
| Mautic\Migrations\Version20201026101117   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20210112162046   | migrated                | 2024-10-25 14:49:42 | 0.257s         |             |
| Mautic\Migrations\Version20210217115150   | migrated                | 2024-10-25 14:49:42 | 0.349s         |             |
| Mautic\Migrations\Version20210420113309   | migrated                | 2024-10-25 14:49:42 | 0.325s         |             |
| Mautic\Migrations\Version20211026152443   | migrated                | 2024-10-25 14:49:43 | 0.312s         |             |
| Mautic\Migrations\Version20211026153057   | migrated                | 2024-10-25 14:49:43 | 0.286s         |             |
| Mautic\Migrations\Version20211110070503   | migrated                | 2024-10-25 14:49:43 | 0.311s         |             |
| Mautic\Migrations\Version20211209022550   | migrated                | 2024-10-25 14:49:44 | 0.042s         |             |
| Mautic\Migrations\Version20220216161028   | migrated                | 2024-10-25 14:49:44 | 0.084s         |             |
| Mautic\Migrations\Version20220429091934   | migrated                | 2024-10-25 14:49:44 | 0.323s         |             |
| Mautic\Migrations\Version20220722074516   | migrated                | 2024-10-25 14:49:44 | 0.352s         |             |
| Mautic\Migrations\Version20221010121758   | migrated                | 2024-10-25 14:49:44 | 0.033s         |             |
| Mautic\Migrations\Version20221014061125   | migrated                | 2024-10-25 14:49:45 | 0.296s         |             |
| Mautic\Migrations\Version20221014081742   | migrated                | 2024-10-25 14:49:45 | 0.337s         |             |
| Mautic\Migrations\Version20221128145933   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230131133732   | migrated                | 2024-10-25 14:49:45 | 0.387s         |             |
| Mautic\Migrations\Version20230307083702   | migrated                | 2024-10-25 14:49:46 | 0.078s         |             |
| Mautic\Migrations\Version20230311195347   | migrated                | 2024-10-25 14:49:46 | 0.003s         |             |
| Mautic\Migrations\Version20230321133733   | migrated                | 2024-10-25 14:49:46 | 0.359s         |             |
| Mautic\Migrations\Version20230424083829   | migrated                | 2024-10-25 14:49:46 | 0.268s         |             |
| Mautic\Migrations\Version20230519154448   | migrated                | 2024-10-25 14:49:46 | 0.3s           |             |
| Mautic\Migrations\Version20230522141144   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230525202700   | migrated                | 2024-10-25 14:49:47 | 0.323s         |             |
| Mautic\Migrations\Version20230606111852   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230615101328   | migrated                | 2024-10-25 14:49:47 | 0.001s         |             |
| Mautic\Migrations\Version20230621074925   | migrated                | 2024-10-25 14:49:47 | 0.605s         |             |
| Mautic\Migrations\Version20230627140512   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20231110103625   | migrated                | 2024-10-25 14:49:48 | 0.001s         |             |
| Mautic\Migrations\Version20231206152313   | migrated                | 2024-10-25 14:49:48 | 0.518s         |             |
| Mautic\Migrations\Version20231207235400   | migrated                | 2024-10-25 14:49:48 | 0.423s         |             |
| Mautic\Migrations\Version20240226114528   | migrated                | 2024-10-25 14:49:49 | 0.371s         |             |
| Mautic\Migrations\Version20240416112112   | migrated                | 2024-10-25 14:49:49 | 0.31s          |             |
| Mautic\Migrations\Version20240708153845   | migrated                | 2024-10-25 14:49:49 | 0.02s          |             |
| Mautic\Migrations\Versionzz20230929183000 | not migrated            |                     |                |             |
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+

[~/mautic]# bin/console doctrine:migrations:latest
 Mautic\Migrations\Versionzz20230929183000

Hi @rcarabelli,

Today was testing time! :wink: Weekly newsletter was sent out.
You’ve said 600 mails per hour, but this seems not to be true.

Starting sending from 5am to 1100 subscribers, the mails weren’t sent out all till 12pm.

This my call within the Script calling 1/10 * * * * in my cronjobs.

/bin/console messenger:consume email --limit=120 --time-limit=480 --memory-limit=256M -vvv >> "$LOGFILE" 2>&1

How to optimize?

Thanks,
Georg

Hey @rcarabelli,
I followed your guide but my emails are still not sending. Just a heads up, I know nothing about code.
As you can see in the image below, I’m using a small segment for test but it remains in the messenger_messages table.

The Doctrine is configured and the only edit I made in your script is this :

  • I change - logs/mautic_consume_detailed.log
  • To - logs/mautic_consume.log

The reason was that the tail command : tail -f /path/to/mautic/var/logs/mautic_consume.log
was returning an error that the file “mautic_consume_detailed.log” doesn’t exist.

Can you please point me to the right direction?