Problem/Motivation
My server has multiple network interfaces, each with its own IP address.
Due to the hosting provider's security policy, outgoing connections to SMTP (port 587) are only allowed from a specific IP address — not from the default one.
Currently, Drupal does not provide a way to specify which local IP address should be used for outgoing SMTP connections.
I need the ability to configure Drupal to send emails via SMTP using a specific source IP.
Proposed resolution
The SMTP module is built on top of the PHPMailer library (https://github.com/PHPMailer/PHPMailer), which has the ability to set options such as:
$mail->SMTPOptions = [
'socket' => [
'bindto' => '217.253.72.159:0',
],
];The proposed resolution is to add a new configuration option in the module form to specify the outgoing source IP, and inject this value into the corresponding PHPMailer settings.
Remaining tasks
- Add a new "Outgoing IP Address" field to the SMTP module configuration form.
- Use the value of this field when configuring PHPMailer for outgoing emails.
User interface changes
A new text field will be added to the SMTP module configuration form, allowing the administrator to specify the outgoing source IP address for SMTP connections.
Issue fork smtp-3553774
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dimas11 commentedComment #4
dimas11 commentedComment #5
avpadernoComment #6
bluegeek9 commentedThis is similar to #3230777: Mutual TLS authentication support.
Comment #7
bluegeek9 commentedComment #8
bluegeek9 commentedThere is a merge request that addresses this. Please review.
#3230777: Mutual TLS authentication support
Comment #9
bluegeek9 commentedThis feature was added in #3230777: Mutual TLS authentication support. I am setting the status to fixed to grant everyone credit for their contribution.
Comment #10
bluegeek9 commented