Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

torriv's avatar

fwrite(): SSL: Broken pipe when trying to send mail

hi,

i got everything working locally, but when i try to send email from my shared hosting (siteground), i get this error.

I can't fint any solutions on the web... anyone has any idea?

this is from laravel.log:

production.ERROR: fwrite(): SSL: Broken pipe {"exception":"[object] (ErrorException(code: 0): fwrite(): SSL: Broken pipe at public_html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:231)

and:

[previous exception] [object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at public_html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:445)

i'm using smtp and my mail config is:

/*
    |--------------------------------------------------------------------------
    | SMTP Host Address
    |--------------------------------------------------------------------------
    |
    | Here you may provide the host address of the SMTP server used by your
    | applications. A default option is provided that is compatible with
    | the Mailgun mail service which will provide reliable deliveries.
    |
    */

    'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
        ],

    'host' => env('MAIL_HOST', 'myhost.com'),

    /*
    |--------------------------------------------------------------------------
    | SMTP Host Port
    |--------------------------------------------------------------------------
    |
    | This is the SMTP port used by your application to deliver e-mails to
    | users of the application. Like the host we have set this value to
    | stay compatible with the Mailgun e-mail application by default.
    |
    */

    'port' => env('MAIL_PORT', 465),

    /*
    |--------------------------------------------------------------------------
    | Global "From" Address
    |--------------------------------------------------------------------------
    |
    | You may wish for all e-mails sent by your application to be sent from
    | the same address. Here, you may specify a name and address that is
    | used globally for all e-mails that are sent by your application.
    |
    */

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'myname'),
    ],

    /*
    |--------------------------------------------------------------------------
    | E-Mail Encryption Protocol
    |--------------------------------------------------------------------------
    |
    | Here you may specify the encryption protocol that should be used when
    | the application send e-mail messages. A sensible default using the
    | transport layer security protocol should provide great security.
    |
    */

    'encryption' => env('MAIL_ENCRYPTION', 'ssl'),

    /*
    |--------------------------------------------------------------------------
    | SMTP Server Username
    |--------------------------------------------------------------------------
    |
    | If your SMTP server requires a username for authentication, you should
    | set it here. This will get used to authenticate with your server on
    | connection. You may also set the "password" value below this one.
    |
    */

    'username' => env('[email protected]'),

    'password' => env('mypassword'),

my .env file:

MAIL_DRIVER=smtp
MAIL_HOST=mydomain.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
0 likes
0 replies

Please or to participate in this conversation.