0

My host is about to block port 25 and I'm unsure if WordPress requires port 25 to send emails like password reset, user registration, notifications etc...

3
  • No, WordPress does not have any specific requirements regarding using port 25 or a certain port for sending emails.
    – Sally CJ
    May 9, 2021 at 7:43
  • What exactly are they blocking: outbound traffic on port 25, or outbound traffic except to their SMTP servers, or inbound traffic on port 25? You probably want to route outbound email via their servers, and there's no requirement to support incoming port 25 traffic to send email (and you probably don't need to).
    – Rup
    May 9, 2021 at 22:40
  • Alternatively you can set WordPress up to send outgoing email by some other route that doesn't use SMTP as the first hop from WordPress e.g. Amazon SES or Sendgrid or Postmark or Mailgun or many others - they'll all have WordPress plugins that override wp_mail to use their services instead.
    – Rup
    May 9, 2021 at 22:41

2 Answers 2

0

WordPress sends emails via the wp_mail() method, which, by default, needs port 25 to be enabled in your php.ini settings:

For this function to work, the settings SMTP and smtp_port (default: 25) need to be set in your php.ini file.

You will have to change this setting if you would want to send mails via another port.

4
  • 2
    It says that „a“ port has to be set in php.ini but it could be any. Port 25 is just the default smtp_port value.
    – Luckyfella
    May 9, 2021 at 21:13
  • 1
    You are right, I shall update my answer. May 10, 2021 at 21:38
  • 2
    nice you edited your answer! If you alter the intro-sentence to "WordPress sends emails via the wp_mail() method, which requires the settings SMTP and smtp_port to be set in your php.ini file." I would like it even more :) Otherwise it sounds like it has to be port 25 when you start reading.
    – Luckyfella
    May 11, 2021 at 6:17
  • Thanks, I have updated the wording of my answer. May 11, 2021 at 11:10
1

If you need to use a port other than port 25, you don't have to change this in your php.ini. You can change the port used by wp_mail() by changing the value in phpMailer. phpMailer is what wp_mail() uses when sending an email, and you can change the outbound port used as well as a number of other settings by setting these values when phpMailer is initialized:

add_action( 'phpmailer_init', 'change_my_email_port' );
function change_my_email_port( $phpmailer ) {
    $phpmailer->Port = 587; // Set required port here.
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.