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

  1. Add a new "Outgoing IP Address" field to the SMTP module configuration form.
  2. 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

Command icon 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

dimas11 created an issue. See original summary.

dimas11’s picture

Issue summary: View changes
dimas11’s picture

Status: Active » Needs review
avpaderno’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
bluegeek9’s picture

bluegeek9’s picture

Assigned: Unassigned » bluegeek9
Status: Needs review » Active
bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Needs review

There is a merge request that addresses this. Please review.
#3230777: Mutual TLS authentication support

bluegeek9’s picture

This feature was added in #3230777: Mutual TLS authentication support. I am setting the status to fixed to grant everyone credit for their contribution.

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triage issues and adding more context to existing issues.
  • Flagging SMTP as a favorite on the project page to help others discover it and show your support.
bluegeek9’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.