WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 months ago

#29069 reopened enhancement

Proposal: wp-pluggable.php patch to send email through SMTP, not mail()

Reported by: JanR Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Mail Keywords: close
Focuses: Cc:

Description

Hereby I provide you with a patch to WordPress 3.9.1's wp-includes/pluggable.php file, to enable the use of SMTP as email option. This patch provides several advantages:

  • it allows website owners to send email thought their ISP's SMTP server, instead of using the mail() function and localhost.
  • TLS and SSL encrypted connections are supported, as are alternative SMTP ports

And all this makes it even possible to mail though Gmail's SMTP server.

I dediced to put the email configuration in wp-config.php, so there is a patch for that file too.

The story beind the patches is: I found it kinda strange the WordPress core lacks this functionality out-of-the-box, now more and more hosting providers require to use SMTP and TLS for sending mail from websites. Not to mention beter privacy protection due to the SMTP pipe being encrypted. The in WordPress included PHPMailer version supports these options by default.

The patches are open for improvement.

Regards,

Jan,

Attachments (2)

pluggable.php.patch (1.1 KB) - added by JanR 5 years ago.
patches on wp-includes/pluggable.php and wp-config.php
29069.diff (1.4 KB) - added by michalzuber 5 years ago.

Download all attachments as: .zip

Change History (20)

@JanR
5 years ago

patches on wp-includes/pluggable.php and wp-config.php

#1 @inetbizo
5 years ago

  • Keywords needs-docs needs-codex needs-unit-tests reporter-feedback added
  • Severity changed from normal to trivial
  • Version set to 3.9.1

This would work well with OpenPGP & Commercial CA signed / encrypted body

#2 @SergeyBiryukov
5 years ago

  • Keywords reporter-feedback removed
  • Severity changed from trivial to normal
  • Summary changed from Propasal: wp-pluggable.php patch to send email through SMTP, not mail() to Proposal: wp-pluggable.php patch to send email through SMTP, not mail()

@michalzuber
5 years ago

#3 @michalzuber
5 years ago

Nice one. I think there is no need for addReplyTo also From and FromName are already set above in the code.
Added constants into wp-config-sample.php
Using SMTP is good on shared hosts, more flexible to avoid hosts mail server been blacklisted.

#4 follow-ups: @SergeyBiryukov
5 years ago

wp_mail() is a pluggable function, so these constants won't work if it's replaced by a plugin.

This sounds like plugin territory, and there are plugins for sending emails via SMTP.

#5 in reply to: ↑ 4 @JanR
5 years ago

Replying to SergeyBiryukov:

wp_mail() is a pluggable function, so these constants won't work if it's replaced by a plugin.

This sounds like plugin territory, and there are plugins for sending emails via SMTP.

Not to start a discussion, but the whole point is to remove the need for a plugin. In my opinion, this is such a basic task that should be available in WP's core.

#6 @michalzuber
5 years ago

  • Keywords 2nd-opinion added

I like the idea, but hard to decide what should and shouldn't be part of WP. With this SMTP setting I more inclined to it should be without a need of a plugin. I don't know how many people use for example Email posting (download from POP3 mailbox) and is part of WP, but these SMTP settings would fit into WP Settings->Writing admin page. Other plugins could also use it and the user has to change in one place.
An article why is SMTP better than mail() http://www.jvfconsulting.com/blog/190/PHP_Mail_Function_vs_SMTP_Guaranteed_Delivery.html
In my opinion WP is about quality and it should have this builtin option to better deliver emails.

#7 @JanR
5 years ago

Any news on this?

#8 in reply to: ↑ 4 ; follow-up: @chriscct7
4 years ago

Replying to SergeyBiryukov:

wp_mail() is a pluggable function, so these constants won't work if it's replaced by a plugin.

This sounds like plugin territory, and there are plugins for sending emails via SMTP.

True, but in the case a plugin replaces the function, then it will continue operating as it did before this change, and the constants will simply do nothing.

#9 in reply to: ↑ 8 @SergeyBiryukov
4 years ago

Replying to chriscct7:

True, but in the case a plugin replaces the function, then it will continue operating as it did before this change, and the constants will simply do nothing.

That's the problem, it would be confusing and hard to debug if you don't know where to look.

Still seems like plugin territory to me.

#10 @dd32
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

I'm going to close this as maybelater.
My reasons are as follows

  • WordPress follows the Decisions, Not Options philosophy. WordPress users shouldn't be given options which they don't actually need.
  • Mail sending should just work for users, if it doesn't work with mail() the PHP settings are probably wrong on the host, and something should be done there.
  • Plugins fill the need very well, as shown by the number of plugins and usage figures of them. I am however surprised by the amount of sites utilising SMTP plugins, but I'm not sure all of them actually need them.

In the event that we decide to add native SMTP settings into WordPress, a committer can re-open this. Discussion can also continue while the ticket is closed.

#11 @ocean90
3 years ago

#39465 was marked as a duplicate.

This ticket was mentioned in Slack in #core-multisite by desrosj. View the logs.


2 years ago

#13 @johnbillion
2 years ago

#41344 was marked as a duplicate.

#14 @SergeyBiryukov
3 months ago

#47206 was marked as a duplicate.

#15 @subwebsites
3 months ago

How many years do we need to wait for it to happen:
https://www.youtube.com/watch?v=KliSG4bH0mA

#16 @knutsp
3 months ago

#47206 was marked as a duplicate.

#17 @subwebsites
3 months ago

  • Resolution maybelater deleted
  • Status changed from closed to reopened

Ok, if this is the place I'm to post it then here it is, something needs to get done


How many years do we need to wait for this to happen... http://prntscr.com/nmmq92

https://www.youtube.com/watch?v=KliSG4bH0mA

The other threads never seem to resolve anything, it's like no-one cares

Unless there Police officers here saying this is closed without resolve then we are all in trouble for wanting something better.!!!

#18 @johnbillion
3 months ago

  • Keywords close added; needs-docs needs-codex needs-unit-tests 2nd-opinion removed
  • Version 3.9.1 deleted

This ticket has had no traction in five years because the discussion is resolved. Comments 9 and 10 are from WordPress core committers explaining why this functionality is best suited to plugins.

Note: See TracTickets for help on using tickets.