WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 18 months ago

Last modified 10 months ago

#29069 closed enhancement (maybelater)

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

Reported by: JanR Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: Mail Keywords: needs-docs needs-codex needs-unit-tests 2nd-opinion
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 4 years ago.
patches on wp-includes/pluggable.php and wp-config.php
29069.diff (1.4 KB) - added by michalzuber 4 years ago.

Download all attachments as: .zip

Change History (15)

@JanR
4 years ago

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

#1 @inetbizo
4 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
4 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
4 years ago

#3 @michalzuber
4 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
4 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
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.

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
4 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
4 years ago

Any news on this?

#8 in reply to: ↑ 4 ; follow-up: @chriscct7
3 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
3 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
18 months 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
18 months ago

#39465 was marked as a duplicate.

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


10 months ago

#13 @johnbillion
10 months ago

#41344 was marked as a duplicate.

Note: See TracTickets for help on using tickets.