phpmailerHow do I configure PHPMailer to use a proxy?
PHPMailer can be configured to use a proxy by setting the SMTPOptions
property of the PHPMailer
class instance to an array containing the proxy settings. The example below shows how to configure PHPMailer to use an SOCKS5 proxy.
$mail = new PHPMailer;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
),
'socks' => array(
'host' => 'socks.example.com',
'port' => '1080',
'username' => 'username',
'password' => 'password'
)
);
The code above sets the following properties:
ssl
: An array containing settings for SSL/TLS connection.verify_peer
: Set tofalse
to disable peer verification.verify_peer_name
: Set tofalse
to disable peer name verification.allow_self_signed
: Set totrue
to allow self-signed certificates.
socks
: An array containing settings for the SOCKS5 proxy.host
: The hostname or IP address of the SOCKS5 proxy.port
: The port of the SOCKS5 proxy.username
: The username for the SOCKS5 proxy (optional).password
: The password for the SOCKS5 proxy (optional).
For more information, please refer to the PHPMailer documentation.
More of Phpmailer
- How do I use PHPMailer to attach a ZIP file?
- How can I set up PHPMailer to use Zimbra SMTP?
- How can I configure PHPMailer to support Polish characters?
- How do I configure PHPmailer to use Zoho SMTP?
- How can I use PHPMailer in Yii 1?
- How can I configure PHPMailer to work with GoDaddy?
- How can I troubleshoot a failed PHPMailer SMTP connect()?
- How can I use PHPMailer with Mailtrap?
- How can I use PHPMailer to send emails with a Yahoo account?
- How do I configure PHPMailer to work with Microsoft Exchange?
See more codes...