Skip to content

Commit 0adc937

Browse files
committed
Fix #325: Force IPv4 by default to prevent SSL_ERROR_SYSCALL
- Add 'force_ip_resolve' => 'v4' to default requestOptions - Fixes intermittent SSL connection errors on servers with misconfigured IPv6 - Users can still override to use IPv6 or system default if needed - Update README with Network Connectivity documentation
1 parent c31917a commit 0adc937

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)