Skip to content

Commit 9d5cea2

Browse files
authored
Merge pull request #326 from mshcherb/fix/issue-325-force-ipv4-by-default
Fix #325: Force IPv4 by default to prevent SSL_ERROR_SYSCALL
2 parents 6fa00b6 + 0adc937 commit 9d5cea2

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,24 @@ $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'),
181181

182182
If your account has been moved to Mailjet's US architecture, the URL value you need to set is `api.us.mailjet.com`.
183183

184+
#### Network Connectivity
185+
186+
By default, the library forces IPv4 connections to avoid intermittent SSL connection issues on servers with misconfigured IPv6. This resolves the common `SSL_ERROR_SYSCALL` error.
187+
188+
If you need to use IPv6 or system default, you can override this setting:
189+
190+
```php
191+
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
192+
193+
// Use IPv6
194+
$mj->addRequestOption('force_ip_resolve', 'v6');
195+
196+
// Or use system default (both IPv4 and IPv6)
197+
$mj->addRequestOption('force_ip_resolve', null);
198+
```
199+
200+
**Note:** If you experience intermittent connection failures, ensure IPv4 forcing is enabled (default behavior).
201+
184202
### Disable API call
185203

186204
By default the API call parameter is always enabled. However, you may want to disable it during testing to prevent unnecessary calls to the Mailjet API. This is done by setting the third parameter to `false`:

src/Mailjet/Client.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Client
5252
private array $requestOptions = [
5353
self::TIMEOUT => 15,
5454
self::CONNECT_TIMEOUT => 2,
55+
'force_ip_resolve' => 'v4',
5556
];
5657
/**
5758
* @var string[]

0 commit comments

Comments
 (0)