Skip to content

[4.x]: Problems with custom smtp settings #17913

@tejubhe

Description

@tejubhe

What happened?

Description

Hi I am using custom smtp setting for craftcms .
using below code in config/app.php

 'mailer' => function() {
                // Get the stored email settings
                $settings = App::mailSettings();
 
                // Override the transport adapter class
                $settings->transportType = \craft\mail\transportadapters\Smtp::class;
 
                // Override the transport adapter settings
                $settings->transportSettings = [
                    'host' => getenv('SMTP_HOST'),
                    'port' => getenv('SMTP_PORT'),
                    'useAuthentication' => getenv('SMTP_USERNAME') !== '' ? true : false,
                    'username' => getenv('SMTP_USERNAME'),
                    'password' => getenv('SMTP_PASSWORD'),
                    'encryptionMethod' => getenv('SMTP_ENCRYPTION_METHOD') !== '' ? getenv('SMTP_ENCRYPTION_METHOD') : null,
                    'timeout' => '10'
                ];
 
                $config = App::mailerConfig($settings);
                return Craft::createObject($config);
            },
            'queue' => [
                'ttr' => 600, // 300 default
            ],
            'redis' => [
                'class' => yii\redis\Connection::class,
                'hostname' => getenv('REDIS_HOST'),
                'port' => getenv('REDIS_PORT'),
                'password' => getenv('REDIS_PASSWORD') !== '' ? getenv('REDIS_PASSWORD') : NULL,
                'useSSL' => (getenv('REDIS_USE_SSL') === '1')
            ],

This issue comes after I upgraded to php 8.2.29 , Formie 2.2.5 and having Craft CMS 4.16.13 version .

2025-10-01 16:55:32 [INFO] Submission triggered for individualsForm.
2025-10-01 16:55:32 [INFO] Request context:
$_GET = []

$_POST = [
    'CRAFT_CSRF_TOKEN' => '••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••'
    'action' => 'formie/submissions/submit'
    'submitAction' => 'submit'
    'handle' => 'Form'
    'siteId' => '1'
    'fields' => [
        'firstName' => 'Test'
        'lastName' => 'Testing'
        'phoneNumber' => [
            'number' => ''
        ]
        'email' => 'test@gmail.com'
        'howMuchWouldYouLikeToDiscuss' => ''
        'reasonForEnquiry' => ''
        'iAgreeToReceiveEmail' => ''
        'referringUrl' => ''
        'pageUrl' => ''
        'utmSource' => '{{ craft.app.request.getQueryParam(\'utm_source\') }}'
        'utmMedium' => '{{ craft.app.request.getQueryParam(\'utm_medium\') }}'
        'utmCampaign' => '{{ craft.app.request.getQueryParam(\'utm_campaign\') }}'
        'utmTerm' => '{{ craft.app.request.getQueryParam(\'utm_term\') }}'
        'utmContent' => '{{ craft.app.request.getQueryParam(\'utm_content\') }}'
        'formevent' => 'hard'
    ]
    'location' => ''
    'g-recaptcha-response' => ''
]
2025-10-01 16:55:35 [INFO] Adestra: Opting-out. Field “{iAgreeToReceiveEmail}” has value “No”.
2025-10-01 16:55:35 [INFO] Adestra: Sending payload cancelled by opt-in field.
2025-10-01 16:55:35 [INFO] Request context:
$_GET = []

$_POST = []
2025-10-01 16:55:36 [ERROR] Notification email “Send to Marketing inbox” could not be sent for submission “7785588”. The mailer service failed to send the notification: “”.
2025-10-01 16:55:36 [ERROR] Email payload: {"charset":"utf-8","from":{"noreply@domain.com":"Test"},"replyTo":"","to":{"marketing@domain.com":""},"cc":"","bcc":"","sender":"","subject":"Contact form submission \","body":"<p>\n            <strong>First name<\/strong><br>\n    \n            Tejas Test\n    <\/p><p>\n            <strong>formevent<\/strong><br>\n    \n            hard\n    <\/p>"}
2025-10-01 16:55:36 [INFO] Fail alert not configured to send.
2025-10-01 16:55:36 [INFO] Request context:
$_GET = []

$_POST = []
2025-10-01 16:55:36 [ERROR] Notification email “Send to Mail inbox” could not be sent for submission “7785584”. The mailer service failed to send the notification: “”.
2025-10-01 16:55:36 [ERROR] Email payload: {"charset":"utf-8","from":{"noreply@domain.com":"Test"},"replyTo":"","to":{"marketing@domain.com":""},"cc":"","bcc":"","sender":"","subject":"Contact form submission \","body":"<p>\n            <strong>First name<\/strong><br>\n    \n            Tejas Test\n    <\/p><p>\n            <strong>formevent<\/strong><br>\n    \n            hard\n    <\/p>"}
2025-10-01 16:55:36 [INFO] Fail alert not configured to send.
2025-10-01 16:55:36 [INFO] Request context:
$_GET = []

$_POST = []

Steps to reproduce

Expected behavior

Actual behavior

Craft CMS version

4.16.13

PHP version

8.2.29

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Also I am getting this issue in UAT and prod , when delivering mails, on localhost when i try with mailpit I am able to see the mails there., but in UAT and prod also not getting logs on SMTP relay

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions