Version Description
- 2017-12-21 =
- Fixed: Decrease the factual minimum WordPress version from 3.9 to 3.6.
- Changed: Improve debug output for all mail providers.
Download this release
Release Info
Developer | slaFFik |
Plugin | WP Mail SMTP by WPForms |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.2.0
- languages/wp-mail-smtp.pot +43 -47
- readme.txt +336 -332
- src/Admin/Pages/Auth.php +4 -1
- src/Admin/Pages/Settings.php +18 -4
- src/Admin/Pages/Test.php +33 -50
- src/Core.php +1 -1
- src/Debug.php +118 -0
- src/Providers/Gmail/Auth.php +10 -3
- src/Providers/Gmail/Mailer.php +42 -55
- src/Providers/Gmail/Options.php +2 -2
- src/Providers/Loader.php +9 -5
- src/Providers/Mail/Mailer.php +32 -0
- src/Providers/Mail/Options.php +2 -2
- src/Providers/MailerAbstract.php +60 -4
- src/Providers/MailerInterface.php +14 -79
- src/Providers/Mailgun/Mailer.php +40 -1
- src/Providers/Mailgun/Options.php +2 -2
- src/Providers/{OptionAbstract.php → OptionsAbstract.php} +1 -1
- src/Providers/{OptionInterface.php → OptionsInterface.php} +1 -1
- src/Providers/Pepipost/Mailer.php +15 -0
- src/Providers/Pepipost/Options.php +3 -3
- src/Providers/SMTP/Mailer.php +15 -0
- src/Providers/SMTP/Options.php +2 -2
- src/Providers/Sendgrid/Mailer.php +53 -3
- src/Providers/Sendgrid/Options.php +2 -2
- wp-mail-smtp.php +20 -1
- wp_mail_smtp.php +856 -856
languages/wp-mail-smtp.pot
CHANGED
@@ -46,7 +46,7 @@ msgstr ""
|
|
46 |
msgid "WP Mail SMTP Settings"
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: wp_mail_smtp.php:296, src/Admin/Pages/Settings.php:
|
50 |
msgid "From Email"
|
51 |
msgstr ""
|
52 |
|
@@ -58,7 +58,7 @@ msgstr ""
|
|
58 |
msgid "<strong>Please Note:</strong> You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name<email@domain.com> in this field."
|
59 |
msgstr ""
|
60 |
|
61 |
-
#: wp_mail_smtp.php:315, src/Admin/Pages/Settings.php:
|
62 |
msgid "From Name"
|
63 |
msgstr ""
|
64 |
|
@@ -66,7 +66,7 @@ msgstr ""
|
|
66 |
msgid "You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress."
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: wp_mail_smtp.php:330, wp_mail_smtp.php:335, src/Admin/Pages/Settings.php:
|
70 |
msgid "Mailer"
|
71 |
msgstr ""
|
72 |
|
@@ -86,15 +86,15 @@ msgstr ""
|
|
86 |
msgid "Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s."
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: wp_mail_smtp.php:371, wp_mail_smtp.php:376, src/Admin/Pages/Settings.php:
|
90 |
msgid "Return Path"
|
91 |
msgstr ""
|
92 |
|
93 |
-
#: wp_mail_smtp.php:381, src/Admin/Pages/Settings.php:
|
94 |
msgid "Set the return-path to match the From Email"
|
95 |
msgstr ""
|
96 |
|
97 |
-
#: wp_mail_smtp.php:385, src/Admin/Pages/Settings.php:
|
98 |
msgid "Return Path indicates where non-delivery receipts - or bounce messages - are to be sent."
|
99 |
msgstr ""
|
100 |
|
@@ -118,15 +118,15 @@ msgstr ""
|
|
118 |
msgid "These options only apply if you have chosen to send mail by SMTP above."
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: wp_mail_smtp.php:425, src/Providers/
|
122 |
msgid "SMTP Host"
|
123 |
msgstr ""
|
124 |
|
125 |
-
#: wp_mail_smtp.php:433, wp_mail_smtp.php:551, src/Providers/
|
126 |
msgid "SMTP Port"
|
127 |
msgstr ""
|
128 |
|
129 |
-
#: wp_mail_smtp.php:440, wp_mail_smtp.php:444, wp_mail_smtp.php:559, wp_mail_smtp.php:565, src/Providers/
|
130 |
msgid "Encryption"
|
131 |
msgstr ""
|
132 |
|
@@ -146,7 +146,7 @@ msgstr ""
|
|
146 |
msgid "TLS is not the same as STARTTLS. For most servers SSL is the recommended option."
|
147 |
msgstr ""
|
148 |
|
149 |
-
#: wp_mail_smtp.php:467, wp_mail_smtp.php:471, src/Providers/
|
150 |
msgid "Authentication"
|
151 |
msgstr ""
|
152 |
|
@@ -182,7 +182,7 @@ msgstr ""
|
|
182 |
msgid "You need to signup on %s to get the SMTP username/password."
|
183 |
msgstr ""
|
184 |
|
185 |
-
#: wp_mail_smtp.php:598, src/Admin/Pages/Test.php:
|
186 |
msgid "Send a Test Email"
|
187 |
msgstr ""
|
188 |
|
@@ -198,7 +198,7 @@ msgstr ""
|
|
198 |
msgid "WP Mail SMTP"
|
199 |
msgstr ""
|
200 |
|
201 |
-
#: wp_mail_smtp.php:758, src/Admin/Area.php:370, src/Admin/Pages/Settings.php:
|
202 |
msgid "Settings"
|
203 |
msgstr ""
|
204 |
|
@@ -226,55 +226,55 @@ msgstr ""
|
|
226 |
msgid "Please rate <strong>WP Mail SMTP</strong> <a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">★★★★★</a> on <a href=\"%2$s\" target=\"_blank\">WordPress.org</a> to help us spread the word. Thank you from the WP Mail SMTP team!"
|
227 |
msgstr ""
|
228 |
|
229 |
-
#: src/Providers/
|
230 |
msgid "None"
|
231 |
msgstr ""
|
232 |
|
233 |
-
#: src/Providers/
|
234 |
msgid "SSL"
|
235 |
msgstr ""
|
236 |
|
237 |
-
#: src/Providers/
|
238 |
msgid "TLS"
|
239 |
msgstr ""
|
240 |
|
241 |
-
#: src/Providers/
|
242 |
msgid "For most servers TLS is the recommended option. If your SMTP provider offers both SSL and TLS options, we recommend using TLS."
|
243 |
msgstr ""
|
244 |
|
245 |
-
#: src/Providers/
|
246 |
msgid "Auto TLS"
|
247 |
msgstr ""
|
248 |
|
249 |
-
#: src/Providers/
|
250 |
msgid "On"
|
251 |
msgstr ""
|
252 |
|
253 |
-
#: src/Providers/
|
254 |
msgid "Off"
|
255 |
msgstr ""
|
256 |
|
257 |
-
#: src/Providers/
|
258 |
msgid "By default TLS encryption is automatically used if the server supports it, which is recommended. In some cases, due to server misconfigurations, this can cause issues and may need to be disabled."
|
259 |
msgstr ""
|
260 |
|
261 |
-
#: src/Providers/
|
262 |
msgid "SMTP Username"
|
263 |
msgstr ""
|
264 |
|
265 |
-
#: src/Providers/
|
266 |
msgid "SMTP Password"
|
267 |
msgstr ""
|
268 |
|
269 |
-
#: src/Providers/
|
270 |
msgid "The password is stored in plain text. We highly recommend you setup your password in your WordPress configuration file for improved security; to do this add the lines below to your %s file."
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: src/Providers/
|
274 |
msgid "%1$s requires PHP %2$s to work and does not support your current PHP version %3$s. Please contact your host and request a PHP upgrade to the latest one."
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: src/Providers/
|
278 |
msgid "Meanwhile you can switch to the \"Other SMTP\" Mailer option."
|
279 |
msgstr ""
|
280 |
|
@@ -286,80 +286,76 @@ msgstr ""
|
|
286 |
msgid "General"
|
287 |
msgstr ""
|
288 |
|
289 |
-
#: src/Admin/Pages/Misc.php:67, src/Admin/Pages/Settings.php:
|
290 |
msgid "Save Settings"
|
291 |
msgstr ""
|
292 |
|
293 |
-
#: src/Admin/Pages/Misc.php:95, src/Admin/Pages/Settings.php:
|
294 |
msgid "Settings were successfully saved."
|
295 |
msgstr ""
|
296 |
|
297 |
-
#: src/Admin/Pages/Settings.php:
|
298 |
msgid "Mail"
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: src/Admin/Pages/Settings.php:
|
302 |
msgid "You can specify the email address that emails should be sent from."
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: src/Admin/Pages/Settings.php:
|
306 |
msgid "If you leave this blank, the default one will be used: %s."
|
307 |
msgstr ""
|
308 |
|
309 |
-
#: src/Admin/Pages/Settings.php:
|
310 |
msgid "Please note if you are sending using an email provider (Gmail, Yahoo, Hotmail, Outlook.com, etc) this setting should be your email address for that account."
|
311 |
msgstr ""
|
312 |
|
313 |
-
#: src/Admin/Pages/Settings.php:
|
314 |
msgid "You can specify the name that emails should be sent from."
|
315 |
msgstr ""
|
316 |
|
317 |
-
#: src/Admin/Pages/Settings.php:
|
318 |
msgid "If you leave this blank, the emails will be sent from %s."
|
319 |
msgstr ""
|
320 |
|
321 |
-
#: src/Admin/Pages/Settings.php:
|
322 |
msgid "If unchecked bounce messages may be lost."
|
323 |
msgstr ""
|
324 |
|
325 |
-
#: src/Admin/Pages/Test.php:
|
326 |
msgid "Email Test"
|
327 |
msgstr ""
|
328 |
|
329 |
-
#: src/Admin/Pages/Test.php:
|
330 |
msgid "Send To"
|
331 |
msgstr ""
|
332 |
|
333 |
-
#: src/Admin/Pages/Test.php:
|
334 |
msgid "Type an email address here and then click a button below to generate a test email."
|
335 |
msgstr ""
|
336 |
|
337 |
-
#: src/Admin/Pages/Test.php:
|
338 |
msgid "Send Email"
|
339 |
msgstr ""
|
340 |
|
341 |
-
#: src/Admin/Pages/Test.php:
|
342 |
msgid "Test failed. Please use a valid email address and try to resend the test email."
|
343 |
msgstr ""
|
344 |
|
345 |
-
#: src/Admin/Pages/Test.php:
|
346 |
msgid "Test email to %s"
|
347 |
msgstr ""
|
348 |
|
349 |
-
#: src/Admin/Pages/Test.php:
|
350 |
msgid "This email was sent by %s mailer, and generated by the WP Mail SMTP WordPress plugin."
|
351 |
msgstr ""
|
352 |
|
353 |
-
#: src/Admin/Pages/Test.php:
|
354 |
msgid "Your email was sent successfully!"
|
355 |
msgstr ""
|
356 |
|
357 |
-
#: src/Admin/Pages/Test.php:133
|
358 |
-
msgid "There was a problem while sending a test email."
|
359 |
-
msgstr ""
|
360 |
-
|
361 |
#: src/Admin/Pages/Test.php:134
|
362 |
-
msgid "
|
363 |
msgstr ""
|
364 |
|
365 |
#: src/Admin/Pages/Test.php:136
|
46 |
msgid "WP Mail SMTP Settings"
|
47 |
msgstr ""
|
48 |
|
49 |
+
#: wp_mail_smtp.php:296, src/Admin/Pages/Settings.php:58
|
50 |
msgid "From Email"
|
51 |
msgstr ""
|
52 |
|
58 |
msgid "<strong>Please Note:</strong> You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name<email@domain.com> in this field."
|
59 |
msgstr ""
|
60 |
|
61 |
+
#: wp_mail_smtp.php:315, src/Admin/Pages/Settings.php:85
|
62 |
msgid "From Name"
|
63 |
msgstr ""
|
64 |
|
66 |
msgid "You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress."
|
67 |
msgstr ""
|
68 |
|
69 |
+
#: wp_mail_smtp.php:330, wp_mail_smtp.php:335, src/Admin/Pages/Settings.php:109
|
70 |
msgid "Mailer"
|
71 |
msgstr ""
|
72 |
|
86 |
msgid "Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s."
|
87 |
msgstr ""
|
88 |
|
89 |
+
#: wp_mail_smtp.php:371, wp_mail_smtp.php:376, src/Admin/Pages/Settings.php:148
|
90 |
msgid "Return Path"
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: wp_mail_smtp.php:381, src/Admin/Pages/Settings.php:157
|
94 |
msgid "Set the return-path to match the From Email"
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: wp_mail_smtp.php:385, src/Admin/Pages/Settings.php:160
|
98 |
msgid "Return Path indicates where non-delivery receipts - or bounce messages - are to be sent."
|
99 |
msgstr ""
|
100 |
|
118 |
msgid "These options only apply if you have chosen to send mail by SMTP above."
|
119 |
msgstr ""
|
120 |
|
121 |
+
#: wp_mail_smtp.php:425, src/Providers/OptionsAbstract.php:126
|
122 |
msgid "SMTP Host"
|
123 |
msgstr ""
|
124 |
|
125 |
+
#: wp_mail_smtp.php:433, wp_mail_smtp.php:551, src/Providers/OptionsAbstract.php:140
|
126 |
msgid "SMTP Port"
|
127 |
msgstr ""
|
128 |
|
129 |
+
#: wp_mail_smtp.php:440, wp_mail_smtp.php:444, wp_mail_smtp.php:559, wp_mail_smtp.php:565, src/Providers/OptionsAbstract.php:154
|
130 |
msgid "Encryption"
|
131 |
msgstr ""
|
132 |
|
146 |
msgid "TLS is not the same as STARTTLS. For most servers SSL is the recommended option."
|
147 |
msgstr ""
|
148 |
|
149 |
+
#: wp_mail_smtp.php:467, wp_mail_smtp.php:471, src/Providers/OptionsAbstract.php:216
|
150 |
msgid "Authentication"
|
151 |
msgstr ""
|
152 |
|
182 |
msgid "You need to signup on %s to get the SMTP username/password."
|
183 |
msgstr ""
|
184 |
|
185 |
+
#: wp_mail_smtp.php:598, src/Admin/Pages/Test.php:49
|
186 |
msgid "Send a Test Email"
|
187 |
msgstr ""
|
188 |
|
198 |
msgid "WP Mail SMTP"
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: wp_mail_smtp.php:758, src/Admin/Area.php:370, src/Admin/Pages/Settings.php:26
|
202 |
msgid "Settings"
|
203 |
msgstr ""
|
204 |
|
226 |
msgid "Please rate <strong>WP Mail SMTP</strong> <a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">★★★★★</a> on <a href=\"%2$s\" target=\"_blank\">WordPress.org</a> to help us spread the word. Thank you from the WP Mail SMTP team!"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: src/Providers/OptionsAbstract.php:164
|
230 |
msgid "None"
|
231 |
msgstr ""
|
232 |
|
233 |
+
#: src/Providers/OptionsAbstract.php:173
|
234 |
msgid "SSL"
|
235 |
msgstr ""
|
236 |
|
237 |
+
#: src/Providers/OptionsAbstract.php:182
|
238 |
msgid "TLS"
|
239 |
msgstr ""
|
240 |
|
241 |
+
#: src/Providers/OptionsAbstract.php:186
|
242 |
msgid "For most servers TLS is the recommended option. If your SMTP provider offers both SSL and TLS options, we recommend using TLS."
|
243 |
msgstr ""
|
244 |
|
245 |
+
#: src/Providers/OptionsAbstract.php:194
|
246 |
msgid "Auto TLS"
|
247 |
msgstr ""
|
248 |
|
249 |
+
#: src/Providers/OptionsAbstract.php:204, src/Providers/OptionsAbstract.php:226
|
250 |
msgid "On"
|
251 |
msgstr ""
|
252 |
|
253 |
+
#: src/Providers/OptionsAbstract.php:205, src/Providers/OptionsAbstract.php:227
|
254 |
msgid "Off"
|
255 |
msgstr ""
|
256 |
|
257 |
+
#: src/Providers/OptionsAbstract.php:208
|
258 |
msgid "By default TLS encryption is automatically used if the server supports it, which is recommended. In some cases, due to server misconfigurations, this can cause issues and may need to be disabled."
|
259 |
msgstr ""
|
260 |
|
261 |
+
#: src/Providers/OptionsAbstract.php:235
|
262 |
msgid "SMTP Username"
|
263 |
msgstr ""
|
264 |
|
265 |
+
#: src/Providers/OptionsAbstract.php:249
|
266 |
msgid "SMTP Password"
|
267 |
msgstr ""
|
268 |
|
269 |
+
#: src/Providers/OptionsAbstract.php:263
|
270 |
msgid "The password is stored in plain text. We highly recommend you setup your password in your WordPress configuration file for improved security; to do this add the lines below to your %s file."
|
271 |
msgstr ""
|
272 |
|
273 |
+
#: src/Providers/OptionsAbstract.php:300
|
274 |
msgid "%1$s requires PHP %2$s to work and does not support your current PHP version %3$s. Please contact your host and request a PHP upgrade to the latest one."
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: src/Providers/OptionsAbstract.php:307
|
278 |
msgid "Meanwhile you can switch to the \"Other SMTP\" Mailer option."
|
279 |
msgstr ""
|
280 |
|
286 |
msgid "General"
|
287 |
msgstr ""
|
288 |
|
289 |
+
#: src/Admin/Pages/Misc.php:67, src/Admin/Pages/Settings.php:191
|
290 |
msgid "Save Settings"
|
291 |
msgstr ""
|
292 |
|
293 |
+
#: src/Admin/Pages/Misc.php:95, src/Admin/Pages/Settings.php:246
|
294 |
msgid "Settings were successfully saved."
|
295 |
msgstr ""
|
296 |
|
297 |
+
#: src/Admin/Pages/Settings.php:51
|
298 |
msgid "Mail"
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: src/Admin/Pages/Settings.php:67
|
302 |
msgid "You can specify the email address that emails should be sent from."
|
303 |
msgstr ""
|
304 |
|
305 |
+
#: src/Admin/Pages/Settings.php:71
|
306 |
msgid "If you leave this blank, the default one will be used: %s."
|
307 |
msgstr ""
|
308 |
|
309 |
+
#: src/Admin/Pages/Settings.php:77
|
310 |
msgid "Please note if you are sending using an email provider (Gmail, Yahoo, Hotmail, Outlook.com, etc) this setting should be your email address for that account."
|
311 |
msgstr ""
|
312 |
|
313 |
+
#: src/Admin/Pages/Settings.php:94
|
314 |
msgid "You can specify the name that emails should be sent from."
|
315 |
msgstr ""
|
316 |
|
317 |
+
#: src/Admin/Pages/Settings.php:98
|
318 |
msgid "If you leave this blank, the emails will be sent from %s."
|
319 |
msgstr ""
|
320 |
|
321 |
+
#: src/Admin/Pages/Settings.php:161
|
322 |
msgid "If unchecked bounce messages may be lost."
|
323 |
msgstr ""
|
324 |
|
325 |
+
#: src/Admin/Pages/Test.php:27
|
326 |
msgid "Email Test"
|
327 |
msgstr ""
|
328 |
|
329 |
+
#: src/Admin/Pages/Test.php:56
|
330 |
msgid "Send To"
|
331 |
msgstr ""
|
332 |
|
333 |
+
#: src/Admin/Pages/Test.php:61
|
334 |
msgid "Type an email address here and then click a button below to generate a test email."
|
335 |
msgstr ""
|
336 |
|
337 |
+
#: src/Admin/Pages/Test.php:67
|
338 |
msgid "Send Email"
|
339 |
msgstr ""
|
340 |
|
341 |
+
#: src/Admin/Pages/Test.php:87
|
342 |
msgid "Test failed. Please use a valid email address and try to resend the test email."
|
343 |
msgstr ""
|
344 |
|
345 |
+
#: src/Admin/Pages/Test.php:111
|
346 |
msgid "Test email to %s"
|
347 |
msgstr ""
|
348 |
|
349 |
+
#: src/Admin/Pages/Test.php:114
|
350 |
msgid "This email was sent by %s mailer, and generated by the WP Mail SMTP WordPress plugin."
|
351 |
msgstr ""
|
352 |
|
353 |
+
#: src/Admin/Pages/Test.php:127
|
354 |
msgid "Your email was sent successfully!"
|
355 |
msgstr ""
|
356 |
|
|
|
|
|
|
|
|
|
357 |
#: src/Admin/Pages/Test.php:134
|
358 |
+
msgid "There was a problem while sending a test email. Related debugging output is shown below:"
|
359 |
msgstr ""
|
360 |
|
361 |
#: src/Admin/Pages/Test.php:136
|
readme.txt
CHANGED
@@ -1,332 +1,336 @@
|
|
1 |
-
=== WP Mail SMTP by WPForms ===
|
2 |
-
Contributors: wpforms, jaredatch, smub, slaFFik
|
3 |
-
Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, wp smtp
|
4 |
-
Requires at least: 3.6
|
5 |
-
Tested up to: 4.9
|
6 |
-
Stable tag: trunk
|
7 |
-
Requires PHP: 5.3
|
8 |
-
|
9 |
-
The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 700k sites.
|
10 |
-
|
11 |
-
== Description ==
|
12 |
-
|
13 |
-
= WordPress Mail SMTP Plugin =
|
14 |
-
|
15 |
-
Having problems with your WordPress site not sending emails? You're not alone. Over 700,000 websites use WP Mail SMTP to fix their email deliverability issues.
|
16 |
-
|
17 |
-
WP Mail SMTP fixes your email deliverability by reconfiguring the wp_mail() PHP function to use a proper SMTP provider.
|
18 |
-
|
19 |
-
= What is SMTP? =
|
20 |
-
|
21 |
-
SMTP (Simple Mail Transfer Protocol) is an industry standard for sending emails. SMTP helps increase email deliverability by using proper authentication.
|
22 |
-
|
23 |
-
Popular email clients like Gmail, Yahoo, Outlook, etc are constantly improving their services to reduce email spam. One of the things their spam tools look for is whether an email is originating from the location it claims to be originating from.
|
24 |
-
|
25 |
-
If the proper authentication isn't there, then the emails either go in your SPAM folder or worst not get delivered at all.
|
26 |
-
|
27 |
-
This is a problem for a lot of WordPress sites because by default, WordPress uses the PHP mail function to send emails generated by WordPress or any contact form plugin like <a href="https://wpforms.com/" rel="friend">WPForms</a>.
|
28 |
-
|
29 |
-
The issue is that most <a href"http://www.wpbeginner.com/wordpress-hosting/" rel="friend">WordPress hosting companies</a> don't have their servers properly configured for sending PHP emails.
|
30 |
-
|
31 |
-
The combination of two causes your WordPress emails to not get delivered.
|
32 |
-
|
33 |
-
= How does WP Mail SMTP work? =
|
34 |
-
|
35 |
-
WP Mail SMTP plugin allows you to easily reconfigure the wp_mail() function to use a trusted SMTP provider.
|
36 |
-
|
37 |
-
This helps you fix all WordPress not sending email issues.
|
38 |
-
|
39 |
-
WP Mail SMTP plugin includes four different SMTP setup options:
|
40 |
-
|
41 |
-
1. Mailgun SMTP
|
42 |
-
2. SendGrid SMTP
|
43 |
-
3. Gmail SMTP
|
44 |
-
4. All Other SMTP
|
45 |
-
|
46 |
-
For all options, you can specify the "from name" and "email address" for outgoing emails.
|
47 |
-
|
48 |
-
Instead of having users use different SMTP plugins and workflows for different SMTP providers, we decided to bring it all in one. This is what makes WP Mail SMTP, the best SMTP solution for WordPress.
|
49 |
-
|
50 |
-
= Mailgun SMTP =
|
51 |
-
|
52 |
-
Mailgun SMTP is a popular SMTP service provider that allows you to send large quantities of emails. They allow you to send your first 10,000 emails for free every month.
|
53 |
-
|
54 |
-
WP Mail SMTP plugin offers a native integration with MailGun. All you have to do is connect your Mailgun account, and you will improve your email deliverability.
|
55 |
-
|
56 |
-
Read our <a href="https://wpforms.com/how-to-send-wordpress-emails-with-mailgun/" rel="friend">Mailgun documentation</a> for more details.
|
57 |
-
|
58 |
-
= Gmail SMTP =
|
59 |
-
|
60 |
-
Often bloggers and small business owners don't want to use third-party SMTP services. Well you can use your Gmail or G Suite account for SMTP emails.
|
61 |
-
|
62 |
-
This allows you to use your <a href="http://www.wpbeginner.com/beginners-guide/how-to-setup-a-professional-email-address-with-gmail-and-google-apps/" rel="friend">professional email address</a> and improve email deliverability.
|
63 |
-
|
64 |
-
Unlike other Gmail SMTP plugins, our Gmail SMTP option uses OAuth to authenticate your Google account, keeping your login information 100% secure.
|
65 |
-
|
66 |
-
Read our <a href="https://wpforms.com/how-to-securely-send-wordpress-emails-using-gmail-smtp/" rel="friend">Gmail documentation</a> for more details.
|
67 |
-
|
68 |
-
= SendGrid SMTP =
|
69 |
-
|
70 |
-
SendGrid has a free SMTP plan that you can use to send up to 100 emails per day. With our native SendGrid SMTP integration, you can easily and securely set up SendGrid SMTP on your WordPress site.
|
71 |
-
|
72 |
-
Read our <a href="https://wpforms.com/fix-wordpress-email-notifications-with-sendgrid/" rel="friend">SendGrid documentation</a> for more details.
|
73 |
-
|
74 |
-
= Other SMTP =
|
75 |
-
|
76 |
-
WP Mail SMTP plugin also works with all major email services such as Gmail, Yahoo, Outlook, Microsoft Live, and any other email sending service that offers SMTP.
|
77 |
-
|
78 |
-
You can set the following options:
|
79 |
-
|
80 |
-
* Specify an SMTP host.
|
81 |
-
* Specify an SMTP port.
|
82 |
-
* Choose SSL / TLS encryption.
|
83 |
-
* Choose to use SMTP authentication or not.
|
84 |
-
* Specify an SMTP username and password.
|
85 |
-
|
86 |
-
WP Mail SMTP also gives you the option to insert your password in your wp-config.php file, so it's not visible in your WordPress settings.
|
87 |
-
|
88 |
-
To see recommended settings for the popular services as well as troubleshooting tips, check out our <a href="https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/" rel="friend">SMTP documentation</a>.
|
89 |
-
|
90 |
-
We hope that you find WP Mail SMTP plugin helpful.
|
91 |
-
|
92 |
-
= Credits =
|
93 |
-
|
94 |
-
WP Mail SMTP plugin was originally created by Callum Macdonald. It is now owned and maintained by the team behind <a href="https://wpforms.com/" rel="friend">WPForms</a> - the best drag & drop form builder for WordPress.
|
95 |
-
|
96 |
-
You can try the <a href="https://wordpress.org/plugins/wpforms-lite/" rel="friend">free version of WPForms plugin</a> to see why it's the best in the market.
|
97 |
-
|
98 |
-
= What's Next =
|
99 |
-
|
100 |
-
If you like this plugin, then please consider checking out our other popular plugins:
|
101 |
-
|
102 |
-
* <a href="http://optinmonster.com/" rel="friend" title="OptinMonster">OptinMonster</a> - Get More Email Subscribers
|
103 |
-
* <a href="https://www.monsterinsights.com/" rel="friend" title="MonsterInsights">MonsterInsights</a> - Best Google Analytics Plugin for WordPress
|
104 |
-
|
105 |
-
Visit <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> to learn from our <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress Tutorials</a> and find out about other <a href="http://www.wpbeginner.com/category/plugins/" rel="friend" title="Best WordPress Plugins">best WordPress plugins</a>.
|
106 |
-
|
107 |
-
== Installation ==
|
108 |
-
|
109 |
-
1. Install WP Mail SMTP by WPForms either via the WordPress.org plugin repository or by uploading the files to your server. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>)
|
110 |
-
2. Activate WP Mail SMTP by WPForms.
|
111 |
-
3. Navigate to the Settings area of WP Mail SMTP in the WordPress admin.
|
112 |
-
4. Choose your SMTP option (Mailgun SMTP, SendGrid SMTP, Gmail SMTP, or Other SMTP) and follow the instructions to set it up.
|
113 |
-
5. Want to support us? Consider trying <a href="https://wpforms.com/?utm_source=wprepo&utm_medium=link&utm_campaign=liteversion" rel="friend" title="WPForms">WPForms Pro</a> - the best WordPress contact form plugin!
|
114 |
-
|
115 |
-
== Frequently Asked Questions ==
|
116 |
-
|
117 |
-
= Can I use this plugin to send email via Gmail, G Suite, Outlook.com, Office 365, Hotmail, Yahoo, or AOL SMTP? =
|
118 |
-
|
119 |
-
Yes! We have extensive documentation that covers setting up SMTP most popular email services.
|
120 |
-
|
121 |
-
<a href="https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/" rel="friend">Read our docs</a> to see the correct SMTP settings for each service.
|
122 |
-
|
123 |
-
= Help! I need support or have an issue. =
|
124 |
-
|
125 |
-
Please read <a href="https://wordpress.org/support/topic/wp-mail-smtp-support-policy/">our support policy</a> for more information.
|
126 |
-
|
127 |
-
= I found a bug, now what? =
|
128 |
-
|
129 |
-
If you've stumbled upon a bug, the best place to report it is in the <a href="https://github.com/awesomemotive/wp-mail-smtp">WP Mail SMTP GitHub repository</a>. GitHub is where the plugin is actively developed, and posting there will get your issue quickly seen by our developers (myself and Slava). Once posted, we'll review your bug report and triage the bug. When creating an issue, the more details you can add to your report, the faster the bug can be solved.
|
130 |
-
|
131 |
-
= Can you add feature x, y or z to the plugin? =
|
132 |
-
|
133 |
-
Short answer: maybe.
|
134 |
-
|
135 |
-
By all means please contact us to discuss features or options you'd like to see added to the plugin. We can't guarantee to add all of them, but we will consider all sensible requests. We can be contacted here:
|
136 |
-
<a href="https://wpforms.com/contact/" rel="friend">https://wpforms.com/contact/</a>
|
137 |
-
|
138 |
-
== Screenshots ==
|
139 |
-
|
140 |
-
1. WP Mail SMTP Settings page
|
141 |
-
2. Gmail / G Suite settings
|
142 |
-
3. Mailgun settings
|
143 |
-
4. SendGrid settings
|
144 |
-
5. SMTP settings
|
145 |
-
6. Send a Test Email
|
146 |
-
|
147 |
-
== Changelog ==
|
148 |
-
|
149 |
-
= 1.
|
150 |
-
*
|
151 |
-
* Changed: Improve debug output
|
152 |
-
|
153 |
-
|
154 |
-
*
|
155 |
-
*
|
156 |
-
*
|
157 |
-
*
|
158 |
-
|
159 |
-
|
160 |
-
* Fixed:
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
*
|
168 |
-
|
169 |
-
|
170 |
-
* Added:
|
171 |
-
*
|
172 |
-
*
|
173 |
-
*
|
174 |
-
*
|
175 |
-
* Changed:
|
176 |
-
|
177 |
-
|
178 |
-
*
|
179 |
-
* Changed:
|
180 |
-
|
181 |
-
= 0.11.
|
182 |
-
*
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
*
|
187 |
-
|
188 |
-
|
189 |
-
*
|
190 |
-
*
|
191 |
-
*
|
192 |
-
*
|
193 |
-
* Changed:
|
194 |
-
* Changed:
|
195 |
-
|
196 |
-
|
197 |
-
*
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
*
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
*
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
*
|
237 |
-
|
238 |
-
= 0.8.
|
239 |
-
*
|
240 |
-
*
|
241 |
-
|
242 |
-
= 0.8.
|
243 |
-
* Bugfix,
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
|
|
|
|
|
|
|
1 |
+
=== WP Mail SMTP by WPForms ===
|
2 |
+
Contributors: wpforms, jaredatch, smub, slaFFik
|
3 |
+
Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, wp smtp
|
4 |
+
Requires at least: 3.6
|
5 |
+
Tested up to: 4.9
|
6 |
+
Stable tag: trunk
|
7 |
+
Requires PHP: 5.3
|
8 |
+
|
9 |
+
The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 700k sites.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
= WordPress Mail SMTP Plugin =
|
14 |
+
|
15 |
+
Having problems with your WordPress site not sending emails? You're not alone. Over 700,000 websites use WP Mail SMTP to fix their email deliverability issues.
|
16 |
+
|
17 |
+
WP Mail SMTP fixes your email deliverability by reconfiguring the wp_mail() PHP function to use a proper SMTP provider.
|
18 |
+
|
19 |
+
= What is SMTP? =
|
20 |
+
|
21 |
+
SMTP (Simple Mail Transfer Protocol) is an industry standard for sending emails. SMTP helps increase email deliverability by using proper authentication.
|
22 |
+
|
23 |
+
Popular email clients like Gmail, Yahoo, Outlook, etc are constantly improving their services to reduce email spam. One of the things their spam tools look for is whether an email is originating from the location it claims to be originating from.
|
24 |
+
|
25 |
+
If the proper authentication isn't there, then the emails either go in your SPAM folder or worst not get delivered at all.
|
26 |
+
|
27 |
+
This is a problem for a lot of WordPress sites because by default, WordPress uses the PHP mail function to send emails generated by WordPress or any contact form plugin like <a href="https://wpforms.com/" rel="friend">WPForms</a>.
|
28 |
+
|
29 |
+
The issue is that most <a href"http://www.wpbeginner.com/wordpress-hosting/" rel="friend">WordPress hosting companies</a> don't have their servers properly configured for sending PHP emails.
|
30 |
+
|
31 |
+
The combination of two causes your WordPress emails to not get delivered.
|
32 |
+
|
33 |
+
= How does WP Mail SMTP work? =
|
34 |
+
|
35 |
+
WP Mail SMTP plugin allows you to easily reconfigure the wp_mail() function to use a trusted SMTP provider.
|
36 |
+
|
37 |
+
This helps you fix all WordPress not sending email issues.
|
38 |
+
|
39 |
+
WP Mail SMTP plugin includes four different SMTP setup options:
|
40 |
+
|
41 |
+
1. Mailgun SMTP
|
42 |
+
2. SendGrid SMTP
|
43 |
+
3. Gmail SMTP
|
44 |
+
4. All Other SMTP
|
45 |
+
|
46 |
+
For all options, you can specify the "from name" and "email address" for outgoing emails.
|
47 |
+
|
48 |
+
Instead of having users use different SMTP plugins and workflows for different SMTP providers, we decided to bring it all in one. This is what makes WP Mail SMTP, the best SMTP solution for WordPress.
|
49 |
+
|
50 |
+
= Mailgun SMTP =
|
51 |
+
|
52 |
+
Mailgun SMTP is a popular SMTP service provider that allows you to send large quantities of emails. They allow you to send your first 10,000 emails for free every month.
|
53 |
+
|
54 |
+
WP Mail SMTP plugin offers a native integration with MailGun. All you have to do is connect your Mailgun account, and you will improve your email deliverability.
|
55 |
+
|
56 |
+
Read our <a href="https://wpforms.com/how-to-send-wordpress-emails-with-mailgun/" rel="friend">Mailgun documentation</a> for more details.
|
57 |
+
|
58 |
+
= Gmail SMTP =
|
59 |
+
|
60 |
+
Often bloggers and small business owners don't want to use third-party SMTP services. Well you can use your Gmail or G Suite account for SMTP emails.
|
61 |
+
|
62 |
+
This allows you to use your <a href="http://www.wpbeginner.com/beginners-guide/how-to-setup-a-professional-email-address-with-gmail-and-google-apps/" rel="friend">professional email address</a> and improve email deliverability.
|
63 |
+
|
64 |
+
Unlike other Gmail SMTP plugins, our Gmail SMTP option uses OAuth to authenticate your Google account, keeping your login information 100% secure.
|
65 |
+
|
66 |
+
Read our <a href="https://wpforms.com/how-to-securely-send-wordpress-emails-using-gmail-smtp/" rel="friend">Gmail documentation</a> for more details.
|
67 |
+
|
68 |
+
= SendGrid SMTP =
|
69 |
+
|
70 |
+
SendGrid has a free SMTP plan that you can use to send up to 100 emails per day. With our native SendGrid SMTP integration, you can easily and securely set up SendGrid SMTP on your WordPress site.
|
71 |
+
|
72 |
+
Read our <a href="https://wpforms.com/fix-wordpress-email-notifications-with-sendgrid/" rel="friend">SendGrid documentation</a> for more details.
|
73 |
+
|
74 |
+
= Other SMTP =
|
75 |
+
|
76 |
+
WP Mail SMTP plugin also works with all major email services such as Gmail, Yahoo, Outlook, Microsoft Live, and any other email sending service that offers SMTP.
|
77 |
+
|
78 |
+
You can set the following options:
|
79 |
+
|
80 |
+
* Specify an SMTP host.
|
81 |
+
* Specify an SMTP port.
|
82 |
+
* Choose SSL / TLS encryption.
|
83 |
+
* Choose to use SMTP authentication or not.
|
84 |
+
* Specify an SMTP username and password.
|
85 |
+
|
86 |
+
WP Mail SMTP also gives you the option to insert your password in your wp-config.php file, so it's not visible in your WordPress settings.
|
87 |
+
|
88 |
+
To see recommended settings for the popular services as well as troubleshooting tips, check out our <a href="https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/" rel="friend">SMTP documentation</a>.
|
89 |
+
|
90 |
+
We hope that you find WP Mail SMTP plugin helpful.
|
91 |
+
|
92 |
+
= Credits =
|
93 |
+
|
94 |
+
WP Mail SMTP plugin was originally created by Callum Macdonald. It is now owned and maintained by the team behind <a href="https://wpforms.com/" rel="friend">WPForms</a> - the best drag & drop form builder for WordPress.
|
95 |
+
|
96 |
+
You can try the <a href="https://wordpress.org/plugins/wpforms-lite/" rel="friend">free version of WPForms plugin</a> to see why it's the best in the market.
|
97 |
+
|
98 |
+
= What's Next =
|
99 |
+
|
100 |
+
If you like this plugin, then please consider checking out our other popular plugins:
|
101 |
+
|
102 |
+
* <a href="http://optinmonster.com/" rel="friend" title="OptinMonster">OptinMonster</a> - Get More Email Subscribers
|
103 |
+
* <a href="https://www.monsterinsights.com/" rel="friend" title="MonsterInsights">MonsterInsights</a> - Best Google Analytics Plugin for WordPress
|
104 |
+
|
105 |
+
Visit <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> to learn from our <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress Tutorials</a> and find out about other <a href="http://www.wpbeginner.com/category/plugins/" rel="friend" title="Best WordPress Plugins">best WordPress plugins</a>.
|
106 |
+
|
107 |
+
== Installation ==
|
108 |
+
|
109 |
+
1. Install WP Mail SMTP by WPForms either via the WordPress.org plugin repository or by uploading the files to your server. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>)
|
110 |
+
2. Activate WP Mail SMTP by WPForms.
|
111 |
+
3. Navigate to the Settings area of WP Mail SMTP in the WordPress admin.
|
112 |
+
4. Choose your SMTP option (Mailgun SMTP, SendGrid SMTP, Gmail SMTP, or Other SMTP) and follow the instructions to set it up.
|
113 |
+
5. Want to support us? Consider trying <a href="https://wpforms.com/?utm_source=wprepo&utm_medium=link&utm_campaign=liteversion" rel="friend" title="WPForms">WPForms Pro</a> - the best WordPress contact form plugin!
|
114 |
+
|
115 |
+
== Frequently Asked Questions ==
|
116 |
+
|
117 |
+
= Can I use this plugin to send email via Gmail, G Suite, Outlook.com, Office 365, Hotmail, Yahoo, or AOL SMTP? =
|
118 |
+
|
119 |
+
Yes! We have extensive documentation that covers setting up SMTP most popular email services.
|
120 |
+
|
121 |
+
<a href="https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/" rel="friend">Read our docs</a> to see the correct SMTP settings for each service.
|
122 |
+
|
123 |
+
= Help! I need support or have an issue. =
|
124 |
+
|
125 |
+
Please read <a href="https://wordpress.org/support/topic/wp-mail-smtp-support-policy/">our support policy</a> for more information.
|
126 |
+
|
127 |
+
= I found a bug, now what? =
|
128 |
+
|
129 |
+
If you've stumbled upon a bug, the best place to report it is in the <a href="https://github.com/awesomemotive/wp-mail-smtp">WP Mail SMTP GitHub repository</a>. GitHub is where the plugin is actively developed, and posting there will get your issue quickly seen by our developers (myself and Slava). Once posted, we'll review your bug report and triage the bug. When creating an issue, the more details you can add to your report, the faster the bug can be solved.
|
130 |
+
|
131 |
+
= Can you add feature x, y or z to the plugin? =
|
132 |
+
|
133 |
+
Short answer: maybe.
|
134 |
+
|
135 |
+
By all means please contact us to discuss features or options you'd like to see added to the plugin. We can't guarantee to add all of them, but we will consider all sensible requests. We can be contacted here:
|
136 |
+
<a href="https://wpforms.com/contact/" rel="friend">https://wpforms.com/contact/</a>
|
137 |
+
|
138 |
+
== Screenshots ==
|
139 |
+
|
140 |
+
1. WP Mail SMTP Settings page
|
141 |
+
2. Gmail / G Suite settings
|
142 |
+
3. Mailgun settings
|
143 |
+
4. SendGrid settings
|
144 |
+
5. SMTP settings
|
145 |
+
6. Send a Test Email
|
146 |
+
|
147 |
+
== Changelog ==
|
148 |
+
|
149 |
+
= 1.2.0 - 2017-12-21 =
|
150 |
+
* Fixed: Decrease the factual minimum WordPress version from 3.9 to 3.6.
|
151 |
+
* Changed: Improve debug output for all mail providers.
|
152 |
+
|
153 |
+
= 1.1.0 - 2017-12-18 =
|
154 |
+
* Added: New option "Auto TLS" for SMTP mailer. Default is enabled. Migration routine for all sites.
|
155 |
+
* Changed: Improve debug output - clear styles and context-aware content.
|
156 |
+
* Changed: Better exceptions handling for Google authentication process.
|
157 |
+
* Changed: Do not sanitize passwords, api keys etc - as they may contain special characters in certain order and sanitization will break those values.
|
158 |
+
* Changed: Improve wording of some helpful texts inside plugin admin area.
|
159 |
+
* Fixed: Do not include certain files in dependency libraries that are not used by Google mailer. This should stop flagging plugin by Wordfence and VaultPress.
|
160 |
+
* Fixed: Constants usage is working now, to define the SMTP password, for example.
|
161 |
+
* Fixed: Notice for default mailer.
|
162 |
+
|
163 |
+
= 1.0.2 - 2017-12-12 =
|
164 |
+
* Fixed: PHPMailer using incorrect SMTPSecure value.
|
165 |
+
|
166 |
+
= 1.0.1 - 2017-12-12 =
|
167 |
+
* Fixed: Global POST processing conflict.
|
168 |
+
|
169 |
+
= 1.0.0 - 2017-12-12 =
|
170 |
+
* Added: Automatic migration tool to move options from older storage format to a new one.
|
171 |
+
* Added: Added Gmail & G Suite email provider integration - without your email and password.
|
172 |
+
* Added: Added SendGrid email provider integration - using the API key only.
|
173 |
+
* Added: Added Mailgun email provider integration - using the API key and configured domain only.
|
174 |
+
* Added: New compatibility mode - for PHP 5.2 old plugin will be loaded, for PHP 5.3 and higher - new version of admin area and new functionality.
|
175 |
+
* Changed: The new look of the admin area.
|
176 |
+
* Changed: SMTP password field now has "password" type.
|
177 |
+
* Changed: SMTP password field does not display real password at all when using constants in `wp-config.php` to define it.
|
178 |
+
* Changed: Escape properly all translations.
|
179 |
+
* Changed: More helpful test email content (with a mailer name).
|
180 |
+
|
181 |
+
= 0.11.2 - 2017-11-28 =
|
182 |
+
* Added: Setting to hide announcement feed.
|
183 |
+
* Changed: Announcement feed data.
|
184 |
+
|
185 |
+
= 0.11.1 - 2017-10-30 =
|
186 |
+
* Fixed: Older PHP compatibility fix.
|
187 |
+
|
188 |
+
= 0.11 - 2017-10-30 =
|
189 |
+
* Added: Helper description to Return Path option.
|
190 |
+
* Added: Filter `wp_mail_smtp_admin_test_email_smtp_debug` to increase the debug message verbosity.
|
191 |
+
* Added: PHP 5.2 notice.
|
192 |
+
* Added: Announcement feed.
|
193 |
+
* Changed: Localization fixes, proper locale name.
|
194 |
+
* Changed: Code style improvements and optimizations for both HTML and PHP.
|
195 |
+
* Changed: Inputs for emails now have a proper type `email`, instead of a generic `text`.
|
196 |
+
* Changed: Turn off `$phpmailer->SMTPAutoTLS` when `No encryption` option is set to prevent error while sending emails.
|
197 |
+
* Changed: Hide Pepipost for those who are not using it.
|
198 |
+
* Changed: WP CLI support improved.
|
199 |
+
|
200 |
+
= 0.10.1 =
|
201 |
+
* Addition of Pepipost and cleanup of admin page.
|
202 |
+
|
203 |
+
= 0.10.0 =
|
204 |
+
* Addition of Pepipost and cleanup of admin page.
|
205 |
+
|
206 |
+
= 0.9.6 =
|
207 |
+
* Minor security fix, sanitize test email address.
|
208 |
+
|
209 |
+
= 0.9.5 =
|
210 |
+
* Minor security fix, hat tip JD Grimes.
|
211 |
+
|
212 |
+
= 0.9.4 =
|
213 |
+
* Improvement to the test email function, very low priority update.
|
214 |
+
|
215 |
+
= 0.9.3 =
|
216 |
+
* Fixing reported issue with passing by reference. props Adam Conway
|
217 |
+
|
218 |
+
= 0.9.2 =
|
219 |
+
* Removing the deprecation notice.
|
220 |
+
|
221 |
+
= 0.9.1 =
|
222 |
+
* $phpmailer->language became protected in WP 3.2, no longer unset on debug output.
|
223 |
+
|
224 |
+
= 0.9.0 =
|
225 |
+
* Typo in the From email description.
|
226 |
+
* Removed changelog from plugin file, no need to duplicate it.
|
227 |
+
* Optionally set $phpmailer->Sender from from email, helps with sendmail / mail().
|
228 |
+
|
229 |
+
= 0.8.7 =
|
230 |
+
* Fix for a long standing bug that caused an error during plugin activation.
|
231 |
+
|
232 |
+
= 0.8.6 =
|
233 |
+
* The Settings link really does work this time, promise. Apologies for the unnecessary updates.
|
234 |
+
|
235 |
+
= 0.8.5 =
|
236 |
+
* Bugfix, the settings link on the Plugin page was broken by 0.8.4.
|
237 |
+
|
238 |
+
= 0.8.4 =
|
239 |
+
* Minor bugfix, remove use of esc_html() to improve backwards compatibility.
|
240 |
+
* Removed second options page menu props ovidiu.
|
241 |
+
|
242 |
+
= 0.8.3 =
|
243 |
+
* Bugfix, return WPMS_MAIL_FROM_NAME, props nacin.
|
244 |
+
* Add Settings link, props Mike Challis http://profiles.wordpress.org/MikeChallis/
|
245 |
+
|
246 |
+
= 0.8.2 =
|
247 |
+
* Bugfix, call phpmailer_init_smtp() correctly, props Sinklar.
|
248 |
+
|
249 |
+
= 0.8.1 =
|
250 |
+
* Internationalisation improvements.
|
251 |
+
|
252 |
+
= 0.8 =
|
253 |
+
* Added port, SSL/TLS, option whitelisting, validate_email(), and constant options.
|
254 |
+
|
255 |
+
= 0.7 =
|
256 |
+
* Added checks to only override the default from name / email
|
257 |
+
|
258 |
+
= 0.6 =
|
259 |
+
* Added additional SMTP debugging output
|
260 |
+
|
261 |
+
= 0.5.2 =
|
262 |
+
* Fixed a pre 2.3 bug to do with mail from
|
263 |
+
|
264 |
+
= 0.5.1 =
|
265 |
+
* Added a check to display a warning on versions prior to 2.3
|
266 |
+
|
267 |
+
= 0.5.0 =
|
268 |
+
* Upgraded to match 2.3 filters which add a second filter for from name
|
269 |
+
|
270 |
+
= 0.4.2 =
|
271 |
+
* Fixed a bug in 0.4.1 and added more debugging output
|
272 |
+
|
273 |
+
= 0.4.1 =
|
274 |
+
* Added $phpmailer->ErroInfo to the test mail output
|
275 |
+
|
276 |
+
= 0.4 =
|
277 |
+
* Added the test email feature and cleaned up some other bits and pieces
|
278 |
+
|
279 |
+
= 0.3.2 =
|
280 |
+
* Changed to use register_activation_hook for greater compatability
|
281 |
+
|
282 |
+
= 0.3.1 =
|
283 |
+
* Added readme for WP-Plugins.org compatability
|
284 |
+
|
285 |
+
= 0.3 =
|
286 |
+
* Various bugfixes and added From options
|
287 |
+
|
288 |
+
= 0.2 =
|
289 |
+
* Reworked approach as suggested by westi, added options page
|
290 |
+
|
291 |
+
= 0.1 =
|
292 |
+
* Initial approach, copying the wp_mail function and replacing it
|
293 |
+
|
294 |
+
== Upgrade Notice ==
|
295 |
+
|
296 |
+
= 0.10.1 =
|
297 |
+
Addition of Pepipost and cleanup of admin page.
|
298 |
+
|
299 |
+
= 0.10.0 =
|
300 |
+
Addition of Pepipost and cleanup of admin page.
|
301 |
+
|
302 |
+
= 0.9.6 =
|
303 |
+
Minor security fix, sanitize test email address.
|
304 |
+
|
305 |
+
= 0.9.5 =
|
306 |
+
Minor security fix, hat tip JD Grimes.
|
307 |
+
|
308 |
+
= 0.9.4 =
|
309 |
+
Improvement to the test email function, very low priority update.
|
310 |
+
|
311 |
+
= 0.9.3 =
|
312 |
+
Fixing reported issue with passing by reference.
|
313 |
+
|
314 |
+
= 0.9.2 =
|
315 |
+
Removing the deprecation notice.
|
316 |
+
|
317 |
+
= 0.9.1 =
|
318 |
+
Test mail functionality was broken on upgrade to 3.2, now restored.
|
319 |
+
|
320 |
+
= 0.9.0 =
|
321 |
+
Low priority upgrade. Improves the appearance of the options page.
|
322 |
+
|
323 |
+
= 0.8.7 =
|
324 |
+
Very low priority update. Fixes a bug that causes a spurious error during activation.
|
325 |
+
|
326 |
+
= 0.8.6 =
|
327 |
+
Low priority update. The Settings link was still broken in 0.8.5.
|
328 |
+
|
329 |
+
= 0.8.5 =
|
330 |
+
Minor bugfix correcting the Settings link bug introduced in 0.8.4. Very low priority update.
|
331 |
+
|
332 |
+
= 0.8.4 =
|
333 |
+
Minor bugfix for users using constants. Another very low priority upgrade. Apologies for the version creep.
|
334 |
+
|
335 |
+
= 0.8.3 =
|
336 |
+
Minor bugfix for users using constants. Very low priority upgrade.
|
src/Admin/Pages/Auth.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace WPMailSMTP\Admin\Pages;
|
4 |
|
5 |
use WPMailSMTP\Options;
|
|
|
6 |
|
7 |
/**
|
8 |
* Class Auth.
|
@@ -25,7 +26,9 @@ class Auth {
|
|
25 |
|
26 |
$auth = wp_mail_smtp()->get_providers()->get_auth( Options::init()->get( 'mail', 'mailer' ) );
|
27 |
|
28 |
-
$auth
|
|
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
3 |
namespace WPMailSMTP\Admin\Pages;
|
4 |
|
5 |
use WPMailSMTP\Options;
|
6 |
+
use WPMailSMTP\Providers\AuthAbstract;
|
7 |
|
8 |
/**
|
9 |
* Class Auth.
|
26 |
|
27 |
$auth = wp_mail_smtp()->get_providers()->get_auth( Options::init()->get( 'mail', 'mailer' ) );
|
28 |
|
29 |
+
if ( $auth && $auth instanceof AuthAbstract ) {
|
30 |
+
$auth->process();
|
31 |
+
}
|
32 |
}
|
33 |
|
34 |
/**
|
src/Admin/Pages/Settings.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace WPMailSMTP\Admin\Pages;
|
4 |
|
5 |
use WPMailSMTP\Admin\PageAbstract;
|
|
|
6 |
use WPMailSMTP\Options;
|
7 |
use WPMailSMTP\WP;
|
8 |
|
@@ -87,7 +88,7 @@ class Settings extends PageAbstract {
|
|
87 |
<input name="wp-mail-smtp[mail][from_name]" type="text"
|
88 |
value="<?php echo esc_attr( $options->get( 'mail', 'from_name' ) ); ?>"
|
89 |
<?php echo $options->is_const_defined( 'mail', 'from_name' ) ? 'disabled' : ''; ?>
|
90 |
-
id="wp-mail-smtp-setting-
|
91 |
/>
|
92 |
<p class="desc">
|
93 |
<?php esc_html_e( 'You can specify the name that emails should be sent from.', 'wp-mail-smtp' ); ?><br/>
|
@@ -112,6 +113,12 @@ class Settings extends PageAbstract {
|
|
112 |
|
113 |
<?php foreach ( wp_mail_smtp()->get_providers()->get_options_all() as $provider ) : ?>
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
<div class="wp-mail-smtp-mailer <?php echo $mailer === $provider->get_slug() ? 'active' : ''; ?>">
|
116 |
<div class="wp-mail-smtp-mailer-image">
|
117 |
<img src="<?php echo esc_url( $provider->get_logo_url() ); ?>"
|
@@ -146,7 +153,9 @@ class Settings extends PageAbstract {
|
|
146 |
<?php echo $options->is_const_defined( 'mail', 'return_path' ) ? 'disabled' : ''; ?>
|
147 |
id="wp-mail-smtp-setting-return_path"
|
148 |
/>
|
149 |
-
<label for="wp-mail-smtp-setting-return_path"
|
|
|
|
|
150 |
<p class="desc">
|
151 |
<?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?><br/>
|
152 |
<?php esc_html_e( 'If unchecked bounce messages may be lost.', 'wp-mail-smtp' ); ?>
|
@@ -162,7 +171,7 @@ class Settings extends PageAbstract {
|
|
162 |
|
163 |
<!-- Mailer Option Title -->
|
164 |
<?php $provider_desc = $provider->get_description(); ?>
|
165 |
-
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading <?php empty( $provider_desc ) ? 'no-desc' : ''; ?>" id="wp-mail-smtp-setting-row-email-heading">
|
166 |
<div class="wp-mail-smtp-setting-field">
|
167 |
<h2><?php echo $provider->get_title(); ?></h2>
|
168 |
<?php if ( ! empty( $provider_desc ) ) : ?>
|
@@ -197,6 +206,11 @@ class Settings extends PageAbstract {
|
|
197 |
$options = new Options();
|
198 |
$old_opt = $options->get_all();
|
199 |
|
|
|
|
|
|
|
|
|
|
|
200 |
$to_redirect = false;
|
201 |
|
202 |
// Old and new Gmail client id/secret values are different - we need to invalidate tokens and scroll to Auth button.
|
@@ -220,7 +234,7 @@ class Settings extends PageAbstract {
|
|
220 |
// New gmail clients data will be added from new $data, except the old access/refresh_token.
|
221 |
$to_save = array_merge( $old_opt, $data );
|
222 |
|
223 |
-
// All the sanitization is done
|
224 |
$options->set( $to_save );
|
225 |
|
226 |
if ( $to_redirect ) {
|
3 |
namespace WPMailSMTP\Admin\Pages;
|
4 |
|
5 |
use WPMailSMTP\Admin\PageAbstract;
|
6 |
+
use WPMailSMTP\Debug;
|
7 |
use WPMailSMTP\Options;
|
8 |
use WPMailSMTP\WP;
|
9 |
|
88 |
<input name="wp-mail-smtp[mail][from_name]" type="text"
|
89 |
value="<?php echo esc_attr( $options->get( 'mail', 'from_name' ) ); ?>"
|
90 |
<?php echo $options->is_const_defined( 'mail', 'from_name' ) ? 'disabled' : ''; ?>
|
91 |
+
id="wp-mail-smtp-setting-from_name" spellcheck="false"
|
92 |
/>
|
93 |
<p class="desc">
|
94 |
<?php esc_html_e( 'You can specify the name that emails should be sent from.', 'wp-mail-smtp' ); ?><br/>
|
113 |
|
114 |
<?php foreach ( wp_mail_smtp()->get_providers()->get_options_all() as $provider ) : ?>
|
115 |
|
116 |
+
<?php
|
117 |
+
if ( ! $options->is_pepipost_active() && $provider->get_slug() === 'pepipost' ) {
|
118 |
+
continue;
|
119 |
+
}
|
120 |
+
?>
|
121 |
+
|
122 |
<div class="wp-mail-smtp-mailer <?php echo $mailer === $provider->get_slug() ? 'active' : ''; ?>">
|
123 |
<div class="wp-mail-smtp-mailer-image">
|
124 |
<img src="<?php echo esc_url( $provider->get_logo_url() ); ?>"
|
153 |
<?php echo $options->is_const_defined( 'mail', 'return_path' ) ? 'disabled' : ''; ?>
|
154 |
id="wp-mail-smtp-setting-return_path"
|
155 |
/>
|
156 |
+
<label for="wp-mail-smtp-setting-return_path">
|
157 |
+
<?php esc_html_e( 'Set the return-path to match the From Email', 'wp-mail-smtp' ); ?>
|
158 |
+
</label>
|
159 |
<p class="desc">
|
160 |
<?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?><br/>
|
161 |
<?php esc_html_e( 'If unchecked bounce messages may be lost.', 'wp-mail-smtp' ); ?>
|
171 |
|
172 |
<!-- Mailer Option Title -->
|
173 |
<?php $provider_desc = $provider->get_description(); ?>
|
174 |
+
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading <?php echo empty( $provider_desc ) ? 'no-desc' : ''; ?>" id="wp-mail-smtp-setting-row-email-heading">
|
175 |
<div class="wp-mail-smtp-setting-field">
|
176 |
<h2><?php echo $provider->get_title(); ?></h2>
|
177 |
<?php if ( ! empty( $provider_desc ) ) : ?>
|
206 |
$options = new Options();
|
207 |
$old_opt = $options->get_all();
|
208 |
|
209 |
+
// Remove all debug messages when switching mailers.
|
210 |
+
if ( $old_opt['mail']['mailer'] !== $data['mail']['mailer'] ) {
|
211 |
+
Debug::clear();
|
212 |
+
}
|
213 |
+
|
214 |
$to_redirect = false;
|
215 |
|
216 |
// Old and new Gmail client id/secret values are different - we need to invalidate tokens and scroll to Auth button.
|
234 |
// New gmail clients data will be added from new $data, except the old access/refresh_token.
|
235 |
$to_save = array_merge( $old_opt, $data );
|
236 |
|
237 |
+
// All the sanitization is done in Options class.
|
238 |
$options->set( $to_save );
|
239 |
|
240 |
if ( $to_redirect ) {
|
src/Admin/Pages/Test.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Admin\Pages;
|
4 |
|
|
|
5 |
use WPMailSMTP\MailCatcher;
|
6 |
use WPMailSMTP\Options;
|
7 |
use WPMailSMTP\WP;
|
@@ -119,7 +120,7 @@ class Test extends PageAbstract {
|
|
119 |
$smtp_debug = ob_get_clean();
|
120 |
|
121 |
/*
|
122 |
-
*
|
123 |
*/
|
124 |
if ( $result ) {
|
125 |
WP::add_admin_notice(
|
@@ -130,8 +131,7 @@ class Test extends PageAbstract {
|
|
130 |
$error = $this->get_debug_messages( $phpmailer, $smtp_debug );
|
131 |
|
132 |
WP::add_admin_notice(
|
133 |
-
'<p><strong>' . esc_html__( 'There was a problem while sending a test email.', 'wp-mail-smtp' ) . '</strong></p>' .
|
134 |
-
'<p>' . esc_html__( 'The related debugging output is shown below:', 'wp-mail-smtp' ) . '</p>' .
|
135 |
'<blockquote style="border-left:1px solid orange;padding-left:10px">' . $error . '</blockquote>' .
|
136 |
'<p class="description">' . esc_html__( 'Please copy only the content of the error debug message above, identified with an orange left border, into the support forum topic if you experience any issues.', 'wp-mail-smtp' ) . '</p>',
|
137 |
WP::ADMIN_NOTICE_ERROR
|
@@ -144,7 +144,7 @@ class Test extends PageAbstract {
|
|
144 |
*
|
145 |
* @since 1.0.0
|
146 |
*
|
147 |
-
* @param
|
148 |
* @param string $smtp_debug
|
149 |
*
|
150 |
* @return string
|
@@ -168,68 +168,51 @@ class Test extends PageAbstract {
|
|
168 |
* Mailer Debug.
|
169 |
*/
|
170 |
|
171 |
-
$mailer_text = '<strong>
|
172 |
|
173 |
$mailer_text .= '<strong>Mailer:</strong> ' . $phpmailer->Mailer . '<br>';
|
|
|
174 |
|
175 |
// Display different debug info based on the mailer.
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
$mailer_text .=
|
180 |
-
$mailer_text .= '<strong>SMTPSecure:</strong> ' . $this->pvar( $phpmailer->SMTPSecure ) . '<br>';
|
181 |
-
$mailer_text .= '<strong>SMTPAutoTLS:</strong> ' . $this->pvar( $phpmailer->SMTPAutoTLS ) . '<br>';
|
182 |
-
$mailer_text .= '<strong>SMTPAuth:</strong> ' . $this->pvar( $phpmailer->SMTPAuth );
|
183 |
-
if ( ! empty( $phpmailer->SMTPOptions ) ) {
|
184 |
-
$mailer_text .= '<br><strong>SMTPOptions:</strong> <code>' . json_encode( $phpmailer->SMTPOptions ) . '</code>';
|
185 |
-
}
|
186 |
}
|
187 |
|
188 |
/*
|
189 |
-
*
|
190 |
*/
|
191 |
|
192 |
-
$
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
198 |
|
199 |
$errors = apply_filters( 'wp_mail_smtp_admin_test_get_debug_messages', array(
|
200 |
$versions_text,
|
201 |
$mailer_text,
|
|
|
202 |
$smtp_text,
|
203 |
) );
|
204 |
|
205 |
-
return '<pre>' . implode( '<br>', $errors ) . '</pre>';
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Get the proper variable content output to debug.
|
210 |
-
*
|
211 |
-
* @since 1.0.0
|
212 |
-
*
|
213 |
-
* @param mixed $var
|
214 |
-
*
|
215 |
-
* @return string
|
216 |
-
*/
|
217 |
-
protected function pvar( $var = '' ) {
|
218 |
-
|
219 |
-
ob_start();
|
220 |
-
|
221 |
-
echo '<code>';
|
222 |
-
|
223 |
-
if ( is_bool( $var ) || empty( $var ) ) {
|
224 |
-
var_dump( $var );
|
225 |
-
} else {
|
226 |
-
print_r( $var );
|
227 |
-
}
|
228 |
-
|
229 |
-
echo '</code>';
|
230 |
-
|
231 |
-
$output = ob_get_clean();
|
232 |
-
|
233 |
-
return str_replace( array( "\r\n", "\r", "\n" ), '', $output );
|
234 |
}
|
235 |
}
|
2 |
|
3 |
namespace WPMailSMTP\Admin\Pages;
|
4 |
|
5 |
+
use WPMailSMTP\Debug;
|
6 |
use WPMailSMTP\MailCatcher;
|
7 |
use WPMailSMTP\Options;
|
8 |
use WPMailSMTP\WP;
|
120 |
$smtp_debug = ob_get_clean();
|
121 |
|
122 |
/*
|
123 |
+
* Notify a user about the results.
|
124 |
*/
|
125 |
if ( $result ) {
|
126 |
WP::add_admin_notice(
|
131 |
$error = $this->get_debug_messages( $phpmailer, $smtp_debug );
|
132 |
|
133 |
WP::add_admin_notice(
|
134 |
+
'<p><strong>' . esc_html__( 'There was a problem while sending a test email. Related debugging output is shown below:', 'wp-mail-smtp' ) . '</strong></p>' .
|
|
|
135 |
'<blockquote style="border-left:1px solid orange;padding-left:10px">' . $error . '</blockquote>' .
|
136 |
'<p class="description">' . esc_html__( 'Please copy only the content of the error debug message above, identified with an orange left border, into the support forum topic if you experience any issues.', 'wp-mail-smtp' ) . '</p>',
|
137 |
WP::ADMIN_NOTICE_ERROR
|
144 |
*
|
145 |
* @since 1.0.0
|
146 |
*
|
147 |
+
* @param MailCatcher $phpmailer
|
148 |
* @param string $smtp_debug
|
149 |
*
|
150 |
* @return string
|
168 |
* Mailer Debug.
|
169 |
*/
|
170 |
|
171 |
+
$mailer_text = '<strong>Params:</strong><br>';
|
172 |
|
173 |
$mailer_text .= '<strong>Mailer:</strong> ' . $phpmailer->Mailer . '<br>';
|
174 |
+
$mailer_text .= '<strong>Constants:</strong> ' . ( $options->is_const_enabled() ? 'Yes' : 'No' ) . '<br>';
|
175 |
|
176 |
// Display different debug info based on the mailer.
|
177 |
+
$mailer = wp_mail_smtp()->get_providers()->get_mailer( $options->get( 'mail', 'mailer' ), $phpmailer );
|
178 |
+
|
179 |
+
if ( $mailer ) {
|
180 |
+
$mailer_text .= $mailer->get_debug_info();
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
}
|
182 |
|
183 |
/*
|
184 |
+
* General Debug.
|
185 |
*/
|
186 |
|
187 |
+
$debug_text = implode( '<br>', Debug::get() );
|
188 |
+
Debug::clear();
|
189 |
+
if ( ! empty( $debug_text ) ) {
|
190 |
+
$debug_text = '<br><strong>Debug:</strong><br>' . $debug_text . '<br>';
|
191 |
+
}
|
192 |
+
|
193 |
+
/*
|
194 |
+
* SMTP Debug.
|
195 |
+
*/
|
196 |
+
|
197 |
+
$smtp_text = '';
|
198 |
+
if ( $options->is_mailer_smtp() ) {
|
199 |
+
$smtp_text = '<strong>SMTP Debug:</strong><br>';
|
200 |
+
if ( ! empty( $smtp_debug ) ) {
|
201 |
+
$smtp_text .= $smtp_debug;
|
202 |
+
} else {
|
203 |
+
$smtp_text .= '[empty]';
|
204 |
+
}
|
205 |
+
|
206 |
+
array_push( $errors, $smtp_text );
|
207 |
}
|
208 |
|
209 |
$errors = apply_filters( 'wp_mail_smtp_admin_test_get_debug_messages', array(
|
210 |
$versions_text,
|
211 |
$mailer_text,
|
212 |
+
$debug_text,
|
213 |
$smtp_text,
|
214 |
) );
|
215 |
|
216 |
+
return '<pre>' . implode( '<br>', array_filter( $errors ) ) . '</pre>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
}
|
218 |
}
|
src/Core.php
CHANGED
@@ -223,7 +223,7 @@ class Core {
|
|
223 |
// Store the plugin version activated to reference with upgrades.
|
224 |
update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER );
|
225 |
|
226 |
-
// Create and store
|
227 |
$options['mail'] = array(
|
228 |
'from_email' => get_option( 'admin_email' ),
|
229 |
'from_name' => get_bloginfo( 'name' ),
|
223 |
// Store the plugin version activated to reference with upgrades.
|
224 |
update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER );
|
225 |
|
226 |
+
// Create and store initial plugin settings.
|
227 |
$options['mail'] = array(
|
228 |
'from_email' => get_option( 'admin_email' ),
|
229 |
'from_name' => get_bloginfo( 'name' ),
|
src/Debug.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WPMailSMTP;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class Debug that will save all errors or warnings generated by APIs or SMTP
|
7 |
+
* and display in area for administrators.
|
8 |
+
*
|
9 |
+
* Usage example:
|
10 |
+
* Debug::set( 'Some warning: %s', array( '%s' => $e->getMessage() );
|
11 |
+
* $debug = Debug::get(); // array
|
12 |
+
* $debug = Debug::get_last(); // string
|
13 |
+
*
|
14 |
+
* @since 1.2.0
|
15 |
+
*/
|
16 |
+
class Debug {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Key for options table where all messages will be saved to.
|
20 |
+
*/
|
21 |
+
const OPTION_KEY = 'wp_mail_smtp_debug';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Save the debug message to a debug log.
|
25 |
+
* Adds one more to a list, at the end.
|
26 |
+
*
|
27 |
+
* @since 1.2.0
|
28 |
+
*
|
29 |
+
* @param string $message
|
30 |
+
*/
|
31 |
+
public static function set( $message ) {
|
32 |
+
|
33 |
+
if ( ! is_string( $message ) ) {
|
34 |
+
$message = \json_encode( $message );
|
35 |
+
}
|
36 |
+
|
37 |
+
$message = wp_strip_all_tags( $message, false );
|
38 |
+
|
39 |
+
$all = self::get();
|
40 |
+
|
41 |
+
array_push( $all, $message );
|
42 |
+
|
43 |
+
update_option( self::OPTION_KEY, $all, false );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Remove all messages for a debug log.
|
48 |
+
*
|
49 |
+
* @since 1.2.0
|
50 |
+
*/
|
51 |
+
public static function clear() {
|
52 |
+
update_option( self::OPTION_KEY, array(), false );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Retrieve all messages from a debug log.
|
57 |
+
*
|
58 |
+
* @since 1.2.0
|
59 |
+
*
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
public static function get() {
|
63 |
+
|
64 |
+
$all = get_option( self::OPTION_KEY, array() );
|
65 |
+
|
66 |
+
if ( ! is_array( $all ) ) {
|
67 |
+
$all = (array) $all;
|
68 |
+
}
|
69 |
+
|
70 |
+
return $all;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get the last message that was saved to a debug log.
|
75 |
+
*
|
76 |
+
* @since 1.2.0
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public static function get_last() {
|
81 |
+
|
82 |
+
$all = self::get();
|
83 |
+
|
84 |
+
if ( ! empty( $all ) && is_array( $all ) ) {
|
85 |
+
return (string) $all[ count( $all ) - 1 ];
|
86 |
+
}
|
87 |
+
|
88 |
+
return '';
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Get the proper variable content output to debug.
|
93 |
+
*
|
94 |
+
* @since 1.2.0
|
95 |
+
*
|
96 |
+
* @param mixed $var
|
97 |
+
*
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public static function pvar( $var = '' ) {
|
101 |
+
|
102 |
+
ob_start();
|
103 |
+
|
104 |
+
echo '<code>';
|
105 |
+
|
106 |
+
if ( is_bool( $var ) || empty( $var ) ) {
|
107 |
+
var_dump( $var );
|
108 |
+
} else {
|
109 |
+
print_r( $var );
|
110 |
+
}
|
111 |
+
|
112 |
+
echo '</code>';
|
113 |
+
|
114 |
+
$output = ob_get_clean();
|
115 |
+
|
116 |
+
return str_replace( array( "\r\n", "\r", "\n" ), '', $output );
|
117 |
+
}
|
118 |
+
}
|
src/Providers/Gmail/Auth.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Gmail;
|
4 |
|
|
|
5 |
use WPMailSMTP\Options as PluginOptions;
|
6 |
use WPMailSMTP\Providers\AuthAbstract;
|
7 |
|
@@ -38,7 +39,12 @@ class Auth extends AuthAbstract {
|
|
38 |
|
39 |
$options = new PluginOptions();
|
40 |
$this->mailer = $options->get( 'mail', 'mailer' );
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
if ( $this->is_clients_saved() ) {
|
44 |
|
@@ -93,6 +99,7 @@ class Auth extends AuthAbstract {
|
|
93 |
$creds = $client->fetchAccessTokenWithAuthCode( $this->gmail['auth_code'] );
|
94 |
} catch ( \Exception $e ) {
|
95 |
$creds['error'] = $e->getMessage();
|
|
|
96 |
}
|
97 |
|
98 |
// Bail if we have an error.
|
@@ -121,11 +128,11 @@ class Auth extends AuthAbstract {
|
|
121 |
$creds = $client->fetchAccessTokenWithRefreshToken( $refresh );
|
122 |
} catch ( \Exception $e ) {
|
123 |
$creds['error'] = $e->getMessage();
|
|
|
124 |
}
|
125 |
|
126 |
// Bail if we have an error.
|
127 |
if ( ! empty( $creds['error'] ) ) {
|
128 |
-
// TODO: save this error to display to a user later.
|
129 |
return $client;
|
130 |
}
|
131 |
|
@@ -147,6 +154,7 @@ class Auth extends AuthAbstract {
|
|
147 |
|
148 |
// We can't process without saved client_id/secret.
|
149 |
if ( ! $this->is_clients_saved() ) {
|
|
|
150 |
wp_redirect(
|
151 |
add_query_arg(
|
152 |
'error',
|
@@ -266,7 +274,6 @@ class Auth extends AuthAbstract {
|
|
266 |
$all[ $this->mailer ]['auth_code'] = $code;
|
267 |
$this->gmail['auth_code'] = $code;
|
268 |
|
269 |
-
|
270 |
$options->set( $all );
|
271 |
}
|
272 |
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Gmail;
|
4 |
|
5 |
+
use WPMailSMTP\Debug;
|
6 |
use WPMailSMTP\Options as PluginOptions;
|
7 |
use WPMailSMTP\Providers\AuthAbstract;
|
8 |
|
39 |
|
40 |
$options = new PluginOptions();
|
41 |
$this->mailer = $options->get( 'mail', 'mailer' );
|
42 |
+
|
43 |
+
if ( $this->mailer !== 'gmail' ) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->gmail = $options->get_group( $this->mailer );
|
48 |
|
49 |
if ( $this->is_clients_saved() ) {
|
50 |
|
99 |
$creds = $client->fetchAccessTokenWithAuthCode( $this->gmail['auth_code'] );
|
100 |
} catch ( \Exception $e ) {
|
101 |
$creds['error'] = $e->getMessage();
|
102 |
+
Debug::set( $e->getMessage() );
|
103 |
}
|
104 |
|
105 |
// Bail if we have an error.
|
128 |
$creds = $client->fetchAccessTokenWithRefreshToken( $refresh );
|
129 |
} catch ( \Exception $e ) {
|
130 |
$creds['error'] = $e->getMessage();
|
131 |
+
Debug::set( $e->getMessage() );
|
132 |
}
|
133 |
|
134 |
// Bail if we have an error.
|
135 |
if ( ! empty( $creds['error'] ) ) {
|
|
|
136 |
return $client;
|
137 |
}
|
138 |
|
154 |
|
155 |
// We can't process without saved client_id/secret.
|
156 |
if ( ! $this->is_clients_saved() ) {
|
157 |
+
Debug::set( 'There was an error while processing the Google authentication request. Please make sure that you have Client ID and Client Secret both valid and saved.' );
|
158 |
wp_redirect(
|
159 |
add_query_arg(
|
160 |
'error',
|
274 |
$all[ $this->mailer ]['auth_code'] = $code;
|
275 |
$this->gmail['auth_code'] = $code;
|
276 |
|
|
|
277 |
$options->set( $all );
|
278 |
}
|
279 |
|
src/Providers/Gmail/Mailer.php
CHANGED
@@ -2,7 +2,9 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Gmail;
|
4 |
|
|
|
5 |
use WPMailSMTP\Providers\MailerAbstract;
|
|
|
6 |
|
7 |
/**
|
8 |
* Class Mailer.
|
@@ -55,64 +57,22 @@ class Mailer extends MailerAbstract {
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
-
* @since 1.
|
61 |
-
*
|
62 |
-
* @param string $email
|
63 |
-
* @param string $name
|
64 |
-
*/
|
65 |
-
public function set_from( $email, $name ) {
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Set a bunch of email recipients: to, cc, bcc.
|
70 |
-
*
|
71 |
-
* @since 1.0.0
|
72 |
-
*
|
73 |
-
* @param array $recipients
|
74 |
-
*/
|
75 |
-
public function set_recipients( $recipients ) {
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Set the email content.
|
80 |
*
|
81 |
-
* @
|
82 |
-
*
|
83 |
-
* @param string|array $content
|
84 |
-
*/
|
85 |
-
public function set_content( $content ) {
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Set the email attachments.
|
90 |
-
*
|
91 |
-
* @since 1.0.0
|
92 |
-
*
|
93 |
-
* @param array $attachments
|
94 |
-
*/
|
95 |
-
public function set_attachments( $attachments ) {
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Set the email reply_to option.
|
100 |
-
*
|
101 |
-
* @since 1.0.0
|
102 |
-
*
|
103 |
-
* @param array $reply_to
|
104 |
*/
|
105 |
-
public function
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
|
109 |
-
* Set the email return_path (when supported).
|
110 |
-
*
|
111 |
-
* @since 1.0.0
|
112 |
-
*
|
113 |
-
* @param string $email
|
114 |
-
*/
|
115 |
-
public function set_return_path( $email ) {
|
116 |
}
|
117 |
|
118 |
/**
|
@@ -135,7 +95,8 @@ class Mailer extends MailerAbstract {
|
|
135 |
|
136 |
$this->process_response( $response );
|
137 |
} catch ( \Exception $e ) {
|
138 |
-
|
|
|
139 |
return;
|
140 |
}
|
141 |
}
|
@@ -170,4 +131,30 @@ class Mailer extends MailerAbstract {
|
|
170 |
|
171 |
return $is_sent;
|
172 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Gmail;
|
4 |
|
5 |
+
use WPMailSMTP\Debug;
|
6 |
use WPMailSMTP\Providers\MailerAbstract;
|
7 |
+
use WPMailSMTP\WP;
|
8 |
|
9 |
/**
|
10 |
* Class Mailer.
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* Re-use the MailCatcher class methods and properties.
|
61 |
*
|
62 |
+
* @since 1.2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
*
|
64 |
+
* @param \WPMailSMTP\MailCatcher $phpmailer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
*/
|
66 |
+
public function process_phpmailer( $phpmailer ) {
|
67 |
+
// Make sure that we have access to MailCatcher class methods.
|
68 |
+
if (
|
69 |
+
! $phpmailer instanceof \WPMailSMTP\MailCatcher &&
|
70 |
+
! $phpmailer instanceof \PHPMailer
|
71 |
+
) {
|
72 |
+
return;
|
73 |
+
}
|
74 |
|
75 |
+
$this->phpmailer = $phpmailer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
/**
|
95 |
|
96 |
$this->process_response( $response );
|
97 |
} catch ( \Exception $e ) {
|
98 |
+
Debug::set( 'Error while sending via Gmail mailer: ' . $e->getMessage() );
|
99 |
+
|
100 |
return;
|
101 |
}
|
102 |
}
|
131 |
|
132 |
return $is_sent;
|
133 |
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @inheritdoc
|
137 |
+
*/
|
138 |
+
public function get_debug_info() {
|
139 |
+
|
140 |
+
$gmail_text = array();
|
141 |
+
|
142 |
+
$options = new \WPMailSMTP\Options();
|
143 |
+
$gmail = $options->get_group( 'gmail' );
|
144 |
+
|
145 |
+
$gmail_text[] = '<strong>Client ID/Secret:</strong> ' . ( ! empty( $gmail['client_id'] ) && ! empty( $gmail['client_secret'] ) ? 'Yes' : 'No' );
|
146 |
+
$gmail_text[] = '<strong>Auth Code:</strong> ' . ( ! empty( $gmail['auth_code'] ) ? 'Yes' : 'No' );
|
147 |
+
$gmail_text[] = '<strong>Access Token:</strong> ' . ( ! empty( $gmail['access_token'] ) ? 'Yes' : 'No' );
|
148 |
+
|
149 |
+
$gmail_text[] = '<br><strong>Server:</strong>';
|
150 |
+
|
151 |
+
$gmail_text[] = '<strong>OpenSSL:</strong> ' . ( extension_loaded( 'openssl' ) ? 'Yes' : 'No' );
|
152 |
+
$gmail_text[] = '<strong>PHP.allow_url_fopen:</strong> ' . ( ini_get( 'allow_url_fopen' ) ? 'Yes' : 'No' );
|
153 |
+
$gmail_text[] = '<strong>PHP.stream_socket_client():</strong> ' . ( function_exists( 'stream_socket_client' ) ? 'Yes' : 'No' );
|
154 |
+
$gmail_text[] = '<strong>PHP.fsockopen():</strong> ' . ( function_exists( 'fsockopen' ) ? 'Yes' : 'No' );
|
155 |
+
$gmail_text[] = '<strong>PHP.curl_version():</strong> ' . ( function_exists( 'curl_version' ) ? 'Yes' : 'No' );
|
156 |
+
$gmail_text[] = '<strong>Apache.mod_security:</strong> ' . ( in_array( 'mod_security', apache_get_modules(), true ) || in_array( 'mod_security2', apache_get_modules(), true ) ? 'Yes' : 'No' );
|
157 |
+
|
158 |
+
return implode( '<br>', $gmail_text );
|
159 |
+
}
|
160 |
}
|
src/Providers/Gmail/Options.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Gmail;
|
4 |
|
5 |
-
use WPMailSMTP\Providers\
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
class Options extends
|
13 |
|
14 |
/**
|
15 |
* Mailgun constructor.
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Gmail;
|
4 |
|
5 |
+
use WPMailSMTP\Providers\OptionsAbstract;
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
class Options extends OptionsAbstract {
|
13 |
|
14 |
/**
|
15 |
* Mailgun constructor.
|
src/Providers/Loader.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers;
|
4 |
|
|
|
5 |
use WPMailSMTP\MailCatcher;
|
6 |
|
7 |
/**
|
@@ -67,7 +68,7 @@ class Loader {
|
|
67 |
*
|
68 |
* @param string $provider
|
69 |
*
|
70 |
-
* @return \WPMailSMTP\Providers\
|
71 |
*/
|
72 |
public function get_options( $provider ) {
|
73 |
return $this->get_entity( $provider, 'Options' );
|
@@ -78,7 +79,7 @@ class Loader {
|
|
78 |
*
|
79 |
* @since 1.0.0
|
80 |
*
|
81 |
-
* @return \WPMailSMTP\Providers\
|
82 |
*/
|
83 |
public function get_options_all() {
|
84 |
$options = array();
|
@@ -87,7 +88,7 @@ class Loader {
|
|
87 |
|
88 |
$option = $this->get_options( $provider );
|
89 |
|
90 |
-
if ( ! $option instanceof
|
91 |
continue;
|
92 |
}
|
93 |
|
@@ -116,7 +117,10 @@ class Loader {
|
|
116 |
*/
|
117 |
public function get_mailer( $provider, $phpmailer ) {
|
118 |
|
119 |
-
if (
|
|
|
|
|
|
|
120 |
$this->phpmailer = $phpmailer;
|
121 |
}
|
122 |
|
@@ -169,7 +173,7 @@ class Loader {
|
|
169 |
}
|
170 |
}
|
171 |
} catch ( \Exception $e ) {
|
172 |
-
|
173 |
$entity = null;
|
174 |
}
|
175 |
|
2 |
|
3 |
namespace WPMailSMTP\Providers;
|
4 |
|
5 |
+
use WPMailSMTP\Debug;
|
6 |
use WPMailSMTP\MailCatcher;
|
7 |
|
8 |
/**
|
68 |
*
|
69 |
* @param string $provider
|
70 |
*
|
71 |
+
* @return \WPMailSMTP\Providers\OptionsAbstract|null
|
72 |
*/
|
73 |
public function get_options( $provider ) {
|
74 |
return $this->get_entity( $provider, 'Options' );
|
79 |
*
|
80 |
* @since 1.0.0
|
81 |
*
|
82 |
+
* @return \WPMailSMTP\Providers\OptionsAbstract[]
|
83 |
*/
|
84 |
public function get_options_all() {
|
85 |
$options = array();
|
88 |
|
89 |
$option = $this->get_options( $provider );
|
90 |
|
91 |
+
if ( ! $option instanceof OptionsAbstract ) {
|
92 |
continue;
|
93 |
}
|
94 |
|
117 |
*/
|
118 |
public function get_mailer( $provider, $phpmailer ) {
|
119 |
|
120 |
+
if (
|
121 |
+
$phpmailer instanceof MailCatcher ||
|
122 |
+
$phpmailer instanceof \PHPMailer
|
123 |
+
) {
|
124 |
$this->phpmailer = $phpmailer;
|
125 |
}
|
126 |
|
173 |
}
|
174 |
}
|
175 |
} catch ( \Exception $e ) {
|
176 |
+
Debug::set( "There was a problem while retrieving {$request} for {$provider}: {$e->getMessage()}" );
|
177 |
$entity = null;
|
178 |
}
|
179 |
|
src/Providers/Mail/Mailer.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WPMailSMTP\Providers\Mail;
|
4 |
+
|
5 |
+
use WPMailSMTP\Providers\MailerAbstract;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Mailer inherits everything from parent abstract class.
|
9 |
+
* This file is required for a proper work of Loader and \ReflectionClass.
|
10 |
+
*
|
11 |
+
* @package WPMailSMTP\Providers\Mail
|
12 |
+
*/
|
13 |
+
class Mailer extends MailerAbstract {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @inheritdoc
|
17 |
+
*/
|
18 |
+
public function get_debug_info() {
|
19 |
+
|
20 |
+
$mail_text = array();
|
21 |
+
|
22 |
+
$mail_text[] = '<br><strong>Server:</strong>';
|
23 |
+
|
24 |
+
$disabled_functions = ini_get( 'disable_functions' );
|
25 |
+
$disabled = (array) explode( ',', trim( $disabled_functions ) );
|
26 |
+
|
27 |
+
$mail_text[] = '<strong>PHP.mail():</strong> ' . ( in_array( 'mail', $disabled, true ) || ! function_exists( 'mail' ) ? 'No' : 'Yes' );
|
28 |
+
$mail_text[] = '<strong>Apache.mod_security:</strong> ' . ( in_array( 'mod_security', apache_get_modules(), true ) || in_array( 'mod_security2', apache_get_modules(), true ) ? 'Yes' : 'No' );
|
29 |
+
|
30 |
+
return implode( '<br>', $mail_text );
|
31 |
+
}
|
32 |
+
}
|
src/Providers/Mail/Options.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Mail;
|
4 |
|
5 |
-
use WPMailSMTP\Providers\
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
class Options extends
|
13 |
|
14 |
/**
|
15 |
* Mail constructor.
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Mail;
|
4 |
|
5 |
+
use WPMailSMTP\Providers\OptionsAbstract;
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
class Options extends OptionsAbstract {
|
13 |
|
14 |
/**
|
15 |
* Mail constructor.
|
src/Providers/MailerAbstract.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers;
|
4 |
|
|
|
5 |
use WPMailSMTP\MailCatcher;
|
6 |
use WPMailSMTP\Options;
|
7 |
|
@@ -76,10 +77,13 @@ abstract class MailerAbstract implements MailerInterface {
|
|
76 |
*
|
77 |
* @param MailCatcher $phpmailer
|
78 |
*/
|
79 |
-
|
80 |
|
81 |
-
// Make sure that we have access to
|
82 |
-
if (
|
|
|
|
|
|
|
83 |
return;
|
84 |
}
|
85 |
|
@@ -232,11 +236,17 @@ abstract class MailerAbstract implements MailerInterface {
|
|
232 |
protected function process_response( $response ) {
|
233 |
|
234 |
if ( is_wp_error( $response ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
return;
|
236 |
}
|
237 |
|
238 |
if ( isset( $response['body'] ) && $this->is_json( $response['body'] ) ) {
|
239 |
-
$response['body'] = json_decode( $response['body'] );
|
240 |
}
|
241 |
|
242 |
$this->response = $response;
|
@@ -267,11 +277,28 @@ abstract class MailerAbstract implements MailerInterface {
|
|
267 |
|
268 |
if ( wp_remote_retrieve_response_code( $this->response ) === $this->email_sent_code ) {
|
269 |
$is_sent = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
}
|
271 |
|
272 |
return apply_filters( 'wp_mail_smtp_providers_mailer_is_email_sent', $is_sent );
|
273 |
}
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
/**
|
276 |
* @inheritdoc
|
277 |
*/
|
@@ -343,4 +370,33 @@ abstract class MailerAbstract implements MailerInterface {
|
|
343 |
|
344 |
return $merged;
|
345 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
}
|
2 |
|
3 |
namespace WPMailSMTP\Providers;
|
4 |
|
5 |
+
use WPMailSMTP\Debug;
|
6 |
use WPMailSMTP\MailCatcher;
|
7 |
use WPMailSMTP\Options;
|
8 |
|
77 |
*
|
78 |
* @param MailCatcher $phpmailer
|
79 |
*/
|
80 |
+
public function process_phpmailer( $phpmailer ) {
|
81 |
|
82 |
+
// Make sure that we have access to MailCatcher class methods.
|
83 |
+
if (
|
84 |
+
! $phpmailer instanceof MailCatcher &&
|
85 |
+
! $phpmailer instanceof \PHPMailer
|
86 |
+
) {
|
87 |
return;
|
88 |
}
|
89 |
|
236 |
protected function process_response( $response ) {
|
237 |
|
238 |
if ( is_wp_error( $response ) ) {
|
239 |
+
// Save the error text.
|
240 |
+
$errors = $response->get_error_messages();
|
241 |
+
foreach ( $errors as $error ) {
|
242 |
+
Debug::set( $error );
|
243 |
+
}
|
244 |
+
|
245 |
return;
|
246 |
}
|
247 |
|
248 |
if ( isset( $response['body'] ) && $this->is_json( $response['body'] ) ) {
|
249 |
+
$response['body'] = \json_decode( $response['body'] );
|
250 |
}
|
251 |
|
252 |
$this->response = $response;
|
277 |
|
278 |
if ( wp_remote_retrieve_response_code( $this->response ) === $this->email_sent_code ) {
|
279 |
$is_sent = true;
|
280 |
+
} else {
|
281 |
+
$error = $this->get_response_error();
|
282 |
+
|
283 |
+
if ( ! empty( $error ) ) {
|
284 |
+
Debug::set( $error );
|
285 |
+
}
|
286 |
}
|
287 |
|
288 |
return apply_filters( 'wp_mail_smtp_providers_mailer_is_email_sent', $is_sent );
|
289 |
}
|
290 |
|
291 |
+
/**
|
292 |
+
* Should be overwritten when appropriate.
|
293 |
+
*
|
294 |
+
* @since 1.2.0
|
295 |
+
*
|
296 |
+
* @return string
|
297 |
+
*/
|
298 |
+
protected function get_response_error() {
|
299 |
+
return '';
|
300 |
+
}
|
301 |
+
|
302 |
/**
|
303 |
* @inheritdoc
|
304 |
*/
|
370 |
|
371 |
return $merged;
|
372 |
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* This method is relevant to SMTP, Pepipost and Mail.
|
376 |
+
* All other custom mailers should override it with own information.
|
377 |
+
*
|
378 |
+
* @since 1.2.0
|
379 |
+
*
|
380 |
+
* @return string
|
381 |
+
*/
|
382 |
+
public function get_debug_info() {
|
383 |
+
global $phpmailer;
|
384 |
+
|
385 |
+
$smtp_text = array();
|
386 |
+
|
387 |
+
// Mail mailer has nothing to return.
|
388 |
+
if ( $this->options->is_mailer_smtp() ) {
|
389 |
+
$smtp_text[] = '<strong>ErrorInfo:</strong> ' . make_clickable( $phpmailer->ErrorInfo );
|
390 |
+
$smtp_text[] = '<strong>Host:</strong> ' . $phpmailer->Host;
|
391 |
+
$smtp_text[] = '<strong>Port:</strong> ' . $phpmailer->Port;
|
392 |
+
$smtp_text[] = '<strong>SMTPSecure:</strong> ' . Debug::pvar( $phpmailer->SMTPSecure );
|
393 |
+
$smtp_text[] = '<strong>SMTPAutoTLS:</strong> ' . Debug::pvar( $phpmailer->SMTPAutoTLS );
|
394 |
+
$smtp_text[] = '<strong>SMTPAuth:</strong> ' . Debug::pvar( $phpmailer->SMTPAuth );
|
395 |
+
if ( ! empty( $phpmailer->SMTPOptions ) ) {
|
396 |
+
$smtp_text[] = '<strong>SMTPOptions:</strong> <code>' . json_encode( $phpmailer->SMTPOptions ) . '</code>';
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
return implode( '<br>', $smtp_text );
|
401 |
+
}
|
402 |
}
|
src/Providers/MailerInterface.php
CHANGED
@@ -37,103 +37,38 @@ interface MailerInterface {
|
|
37 |
public function is_php_compatible();
|
38 |
|
39 |
/**
|
40 |
-
*
|
41 |
-
*
|
42 |
-
* @since 1.0.0
|
43 |
-
*
|
44 |
-
* @param array $headers
|
45 |
-
*/
|
46 |
-
public function set_headers( $headers );
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Set the email single header.
|
50 |
-
*
|
51 |
-
* @since 1.0.0
|
52 |
-
*
|
53 |
-
* @param string $name
|
54 |
-
* @param string $value
|
55 |
-
*/
|
56 |
-
public function set_header( $name, $value );
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Set email FROM.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
*
|
63 |
-
* @param string $email
|
64 |
-
* @param string $name
|
65 |
-
*/
|
66 |
-
public function set_from( $email, $name );
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Set a bunch of email recipients: to, cc, bcc.
|
70 |
-
*
|
71 |
-
* @since 1.0.0
|
72 |
-
*
|
73 |
-
* @param array $recipients
|
74 |
-
*/
|
75 |
-
public function set_recipients( $recipients );
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Set the email subject.
|
79 |
-
*
|
80 |
-
* @since 1.0.0
|
81 |
-
*
|
82 |
-
* @param string $subject
|
83 |
-
*/
|
84 |
-
public function set_subject( $subject );
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Set the email content.
|
88 |
-
*
|
89 |
-
* @since 1.0.0
|
90 |
-
*
|
91 |
-
* @param string|array $content
|
92 |
-
*/
|
93 |
-
public function set_content( $content );
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Set the email attachments.
|
97 |
-
*
|
98 |
-
* @since 1.0.0
|
99 |
-
*
|
100 |
-
* @param array $attachments
|
101 |
-
*/
|
102 |
-
public function set_attachments( $attachments );
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Set the email reply_to option.
|
106 |
*
|
107 |
* @since 1.0.0
|
108 |
*
|
109 |
-
* @
|
110 |
*/
|
111 |
-
public function
|
112 |
|
113 |
/**
|
114 |
-
*
|
115 |
*
|
116 |
* @since 1.0.0
|
117 |
*
|
118 |
-
* @
|
119 |
*/
|
120 |
-
public function
|
121 |
|
122 |
/**
|
123 |
-
* Get the
|
124 |
*
|
125 |
-
* @since 1.
|
126 |
*
|
127 |
-
* @return
|
128 |
*/
|
129 |
-
public function
|
130 |
|
131 |
/**
|
132 |
-
*
|
133 |
*
|
134 |
-
* @since 1.
|
135 |
*
|
136 |
-
* @
|
137 |
*/
|
138 |
-
public function
|
139 |
}
|
37 |
public function is_php_compatible();
|
38 |
|
39 |
/**
|
40 |
+
* Get the email body.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
*
|
42 |
* @since 1.0.0
|
43 |
*
|
44 |
+
* @return string|array
|
45 |
*/
|
46 |
+
public function get_body();
|
47 |
|
48 |
/**
|
49 |
+
* Get the email headers.
|
50 |
*
|
51 |
* @since 1.0.0
|
52 |
*
|
53 |
+
* @return array
|
54 |
*/
|
55 |
+
public function get_headers();
|
56 |
|
57 |
/**
|
58 |
+
* Get an array of all debug information relevant to the mailer.
|
59 |
*
|
60 |
+
* @since 1.2.0
|
61 |
*
|
62 |
+
* @return array
|
63 |
*/
|
64 |
+
public function get_debug_info();
|
65 |
|
66 |
/**
|
67 |
+
* Re-use the MailCatcher class methods and properties.
|
68 |
*
|
69 |
+
* @since 1.2.0
|
70 |
*
|
71 |
+
* @param \WPMailSMTP\MailCatcher $phpmailer
|
72 |
*/
|
73 |
+
public function process_phpmailer( $phpmailer );
|
74 |
}
|
src/Providers/Mailgun/Mailer.php
CHANGED
@@ -30,7 +30,7 @@ class Mailer extends MailerAbstract {
|
|
30 |
*/
|
31 |
public function __construct( $phpmailer ) {
|
32 |
|
33 |
-
// We want to prefill everything from \
|
34 |
parent::__construct( $phpmailer );
|
35 |
|
36 |
/*
|
@@ -296,4 +296,43 @@ class Mailer extends MailerAbstract {
|
|
296 |
)
|
297 |
);
|
298 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
30 |
*/
|
31 |
public function __construct( $phpmailer ) {
|
32 |
|
33 |
+
// We want to prefill everything from \WPMailSMTP\MailCatcher class, which extends \PHPMailer.
|
34 |
parent::__construct( $phpmailer );
|
35 |
|
36 |
/*
|
296 |
)
|
297 |
);
|
298 |
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Get a Mailgun-specific response with a helpful error.
|
302 |
+
*
|
303 |
+
* @since 1.2.0
|
304 |
+
*
|
305 |
+
* @return string
|
306 |
+
*/
|
307 |
+
protected function get_response_error() {
|
308 |
+
|
309 |
+
$body = (array) wp_remote_retrieve_body( $this->response );
|
310 |
+
|
311 |
+
$error_text = array();
|
312 |
+
|
313 |
+
if ( ! empty( $body['message'] ) ) {
|
314 |
+
if ( ! is_string( $body['message'] ) ) {
|
315 |
+
$error_text[] = \json_encode( $body['message'] );
|
316 |
+
} else {
|
317 |
+
$error_text[] = $body['message'];
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
return implode( '<br>', $error_text );
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* @inheritdoc
|
326 |
+
*/
|
327 |
+
public function get_debug_info() {
|
328 |
+
|
329 |
+
$mg_text = array();
|
330 |
+
|
331 |
+
$options = new \WPMailSMTP\Options();
|
332 |
+
$mailgun = $options->get_group( 'mailgun' );
|
333 |
+
|
334 |
+
$mg_text[] = '<strong>Api Key / Domain:</strong> ' . ( ! empty( $mailgun['api_key'] ) && ! empty( $mailgun['domain'] ) ? 'Yes' : 'No' );
|
335 |
+
|
336 |
+
return implode( '<br>', $mg_text );
|
337 |
+
}
|
338 |
}
|
src/Providers/Mailgun/Options.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Mailgun;
|
4 |
|
5 |
-
use WPMailSMTP\Providers\
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
class Options extends
|
13 |
|
14 |
/**
|
15 |
* Mailgun constructor.
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Mailgun;
|
4 |
|
5 |
+
use WPMailSMTP\Providers\OptionsAbstract;
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
class Options extends OptionsAbstract {
|
13 |
|
14 |
/**
|
15 |
* Mailgun constructor.
|
src/Providers/{OptionAbstract.php → OptionsAbstract.php}
RENAMED
@@ -9,7 +9,7 @@ use WPMailSMTP\Options;
|
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
abstract class
|
13 |
|
14 |
/**
|
15 |
* @var string
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
abstract class OptionsAbstract implements OptionsInterface {
|
13 |
|
14 |
/**
|
15 |
* @var string
|
src/Providers/{OptionInterface.php → OptionsInterface.php}
RENAMED
@@ -8,7 +8,7 @@ namespace WPMailSMTP\Providers;
|
|
8 |
*
|
9 |
* @since 1.0.0
|
10 |
*/
|
11 |
-
interface
|
12 |
|
13 |
/**
|
14 |
* Get the mailer provider slug.
|
8 |
*
|
9 |
* @since 1.0.0
|
10 |
*/
|
11 |
+
interface OptionsInterface {
|
12 |
|
13 |
/**
|
14 |
* Get the mailer provider slug.
|
src/Providers/Pepipost/Mailer.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WPMailSMTP\Providers\Pepipost;
|
4 |
+
|
5 |
+
use WPMailSMTP\Providers\MailerAbstract;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Mailer inherits everything from parent abstract class.
|
9 |
+
* This file is required for a proper work of Loader and \ReflectionClass.
|
10 |
+
*
|
11 |
+
* @package WPMailSMTP\Providers\Pepipost
|
12 |
+
*/
|
13 |
+
class Mailer extends MailerAbstract {
|
14 |
+
|
15 |
+
}
|
src/Providers/Pepipost/Options.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Pepipost;
|
4 |
|
5 |
-
use WPMailSMTP\Providers\
|
6 |
|
7 |
/**
|
8 |
-
* Class
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
class
|
13 |
|
14 |
/**
|
15 |
* Pepipost constructor.
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Pepipost;
|
4 |
|
5 |
+
use WPMailSMTP\Providers\OptionsAbstract;
|
6 |
|
7 |
/**
|
8 |
+
* Class Options.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
class Options extends OptionsAbstract {
|
13 |
|
14 |
/**
|
15 |
* Pepipost constructor.
|
src/Providers/SMTP/Mailer.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WPMailSMTP\Providers\SMTP;
|
4 |
+
|
5 |
+
use WPMailSMTP\Providers\MailerAbstract;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Mailer inherits everything from parent abstract class.
|
9 |
+
* This file is required for a proper work of Loader and \ReflectionClass.
|
10 |
+
*
|
11 |
+
* @package WPMailSMTP\Providers\SMTP
|
12 |
+
*/
|
13 |
+
class Mailer extends MailerAbstract {
|
14 |
+
|
15 |
+
}
|
src/Providers/SMTP/Options.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\SMTP;
|
4 |
|
5 |
-
use WPMailSMTP\Providers\
|
6 |
|
7 |
/**
|
8 |
* Class SMTP.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
class Options extends
|
13 |
|
14 |
/**
|
15 |
* SMTP constructor.
|
2 |
|
3 |
namespace WPMailSMTP\Providers\SMTP;
|
4 |
|
5 |
+
use WPMailSMTP\Providers\OptionsAbstract;
|
6 |
|
7 |
/**
|
8 |
* Class SMTP.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
class Options extends OptionsAbstract {
|
13 |
|
14 |
/**
|
15 |
* SMTP constructor.
|
src/Providers/Sendgrid/Mailer.php
CHANGED
@@ -30,11 +30,11 @@ class Mailer extends MailerAbstract {
|
|
30 |
*
|
31 |
* @since 1.0.0
|
32 |
*
|
33 |
-
* @param \
|
34 |
*/
|
35 |
public function __construct( $phpmailer ) {
|
36 |
|
37 |
-
// We want to prefill everything from \
|
38 |
parent::__construct( $phpmailer );
|
39 |
|
40 |
$this->set_header( 'Authorization', 'Bearer ' . $this->options->get( $this->mailer, 'api_key' ) );
|
@@ -213,7 +213,8 @@ class Mailer extends MailerAbstract {
|
|
213 |
if ( is_file( $attachment[0] ) && is_readable( $attachment[0] ) ) {
|
214 |
$file = file_get_contents( $attachment[0] );
|
215 |
}
|
216 |
-
}
|
|
|
217 |
$file = false;
|
218 |
}
|
219 |
|
@@ -291,4 +292,53 @@ class Mailer extends MailerAbstract {
|
|
291 |
*/
|
292 |
public function set_return_path( $email ) {
|
293 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
}
|
30 |
*
|
31 |
* @since 1.0.0
|
32 |
*
|
33 |
+
* @param \WPMailSMTP\MailCatcher $phpmailer
|
34 |
*/
|
35 |
public function __construct( $phpmailer ) {
|
36 |
|
37 |
+
// We want to prefill everything from \WPMailSMTP\MailCatcher class, which extends \PHPMailer.
|
38 |
parent::__construct( $phpmailer );
|
39 |
|
40 |
$this->set_header( 'Authorization', 'Bearer ' . $this->options->get( $this->mailer, 'api_key' ) );
|
213 |
if ( is_file( $attachment[0] ) && is_readable( $attachment[0] ) ) {
|
214 |
$file = file_get_contents( $attachment[0] );
|
215 |
}
|
216 |
+
}
|
217 |
+
catch ( \Exception $e ) {
|
218 |
$file = false;
|
219 |
}
|
220 |
|
292 |
*/
|
293 |
public function set_return_path( $email ) {
|
294 |
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Get a SendGrid-specific response with a helpful error.
|
298 |
+
*
|
299 |
+
* @since 1.2.0
|
300 |
+
*
|
301 |
+
* @return string
|
302 |
+
*/
|
303 |
+
protected function get_response_error() {
|
304 |
+
|
305 |
+
$body = (array) wp_remote_retrieve_body( $this->response );
|
306 |
+
|
307 |
+
$error_text = array();
|
308 |
+
|
309 |
+
if ( ! empty( $body['errors'] ) ) {
|
310 |
+
foreach ( $body['errors'] as $error ) {
|
311 |
+
if ( property_exists( $error, 'message' ) ) {
|
312 |
+
// Prepare additional information from SendGrid API.
|
313 |
+
$extra = '';
|
314 |
+
if ( property_exists( $error, 'field' ) && ! empty( $error->field ) ) {
|
315 |
+
$extra .= $error->field . '; ';
|
316 |
+
}
|
317 |
+
if ( property_exists( $error, 'help' ) && ! empty( $error->help ) ) {
|
318 |
+
$extra .= $error->help;
|
319 |
+
}
|
320 |
+
|
321 |
+
// Assign both the main message and perhaps extra information, if exists.
|
322 |
+
$error_text[] = $error->message . ( ! empty( $extra ) ? ' - ' . $extra : '' );
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
return implode( '<br>', $error_text );
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* @inheritdoc
|
332 |
+
*/
|
333 |
+
public function get_debug_info() {
|
334 |
+
|
335 |
+
$mg_text = array();
|
336 |
+
|
337 |
+
$options = new \WPMailSMTP\Options();
|
338 |
+
$mailgun = $options->get_group( 'sendgrid' );
|
339 |
+
|
340 |
+
$mg_text[] = '<strong>Api Key:</strong> ' . ( ! empty( $mailgun['api_key'] ) ? 'Yes' : 'No' );
|
341 |
+
|
342 |
+
return implode( '<br>', $mg_text );
|
343 |
+
}
|
344 |
}
|
src/Providers/Sendgrid/Options.php
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Sendgrid;
|
4 |
|
5 |
-
use WPMailSMTP\Providers\
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
-
class Options extends
|
13 |
|
14 |
/**
|
15 |
* Options constructor.
|
2 |
|
3 |
namespace WPMailSMTP\Providers\Sendgrid;
|
4 |
|
5 |
+
use WPMailSMTP\Providers\OptionsAbstract;
|
6 |
|
7 |
/**
|
8 |
* Class Option.
|
9 |
*
|
10 |
* @since 1.0.0
|
11 |
*/
|
12 |
+
class Options extends OptionsAbstract {
|
13 |
|
14 |
/**
|
15 |
* Options constructor.
|
wp-mail-smtp.php
CHANGED
@@ -28,8 +28,27 @@ spl_autoload_register( function ( $class ) {
|
|
28 |
// Get the relative class name.
|
29 |
$relative_class = substr( $class, strlen( $plugin_space ) + 1 );
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
// Prepare a path to a file.
|
32 |
-
$file =
|
33 |
|
34 |
// If the file exists, require it.
|
35 |
if ( is_readable( $file ) ) {
|
28 |
// Get the relative class name.
|
29 |
$relative_class = substr( $class, strlen( $plugin_space ) + 1 );
|
30 |
|
31 |
+
/**
|
32 |
+
* Normalize a filesystem path.
|
33 |
+
* Copy of the `wp_normalize_path()` from WordPress 3.9.
|
34 |
+
*
|
35 |
+
* @since 1.2.0
|
36 |
+
*
|
37 |
+
* @param string $path
|
38 |
+
*
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
$normalize = function( $path ) {
|
42 |
+
$path = str_replace( '\\', '/', $path );
|
43 |
+
$path = preg_replace( '|(?<=.)/+|', '/', $path );
|
44 |
+
if ( ':' === substr( $path, 1, 1 ) ) {
|
45 |
+
$path = ucfirst( $path );
|
46 |
+
}
|
47 |
+
return $path;
|
48 |
+
};
|
49 |
+
|
50 |
// Prepare a path to a file.
|
51 |
+
$file = $normalize( $base_dir . $relative_class . '.php' );
|
52 |
|
53 |
// If the file exists, require it.
|
54 |
if ( is_readable( $file ) ) {
|
wp_mail_smtp.php
CHANGED
@@ -1,856 +1,856 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: WP Mail SMTP
|
4 |
-
* Version: 1.
|
5 |
-
* Plugin URI: https://wpforms.com/
|
6 |
-
* Description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage the settings.
|
7 |
-
* Author: WPForms
|
8 |
-
* Author URI: https://wpforms.com/
|
9 |
-
* Text Domain: wp-mail-smtp
|
10 |
-
* Domain Path: /languages
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @author WPForms
|
15 |
-
* @copyright WPForms, 2007-17, All Rights Reserved
|
16 |
-
* This code is released under the GPL licence version 3 or later, available here
|
17 |
-
* http://www.gnu.org/licenses/gpl.txt
|
18 |
-
*/
|
19 |
-
|
20 |
-
define( 'WPMS_PLUGIN_VER', '1.
|
21 |
-
define( 'WPMS_PHP_VER', '5.3' );
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Setting options in wp-config.php
|
25 |
-
*
|
26 |
-
* Specifically aimed at WPMU users, you can set the options for this plugin as
|
27 |
-
* constants in wp-config.php. This disables the plugin's admin page and may
|
28 |
-
* improve performance very slightly. Copy the code below into wp-config.php.
|
29 |
-
*/
|
30 |
-
|
31 |
-
/*
|
32 |
-
define('WPMS_ON', true);
|
33 |
-
define('WPMS_MAIL_FROM', 'From Email');
|
34 |
-
define('WPMS_MAIL_FROM_NAME', 'From Name');
|
35 |
-
define('WPMS_MAILER', 'smtp'); // Possible values 'smtp', 'mail', or 'sendmail'
|
36 |
-
define('WPMS_SET_RETURN_PATH', 'false'); // Sets $phpmailer->Sender if true
|
37 |
-
define('WPMS_SMTP_HOST', 'localhost'); // The SMTP mail host
|
38 |
-
define('WPMS_SMTP_PORT', 25); // The SMTP server port number
|
39 |
-
define('WPMS_SSL', ''); // Possible values '', 'ssl', 'tls' - note TLS is not STARTTLS
|
40 |
-
define('WPMS_SMTP_AUTH', true); // True turns on SMTP authentication, false turns it off
|
41 |
-
define('WPMS_SMTP_USER', 'username'); // SMTP authentication username, only used if WPMS_SMTP_AUTH is true
|
42 |
-
define('WPMS_SMTP_PASS', 'password'); // SMTP authentication password, only used if WPMS_SMTP_AUTH is true
|
43 |
-
*/
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Newer PHP version 5.3+ will be handled a lot differently,
|
47 |
-
* with better code and newer logic.
|
48 |
-
*
|
49 |
-
* @since 1.0.0
|
50 |
-
*/
|
51 |
-
if ( version_compare( phpversion(), WPMS_PHP_VER, '>=' ) ) {
|
52 |
-
require_once dirname( __FILE__ ) . '/wp-mail-smtp.php';
|
53 |
-
return;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Array of options and their default values.
|
58 |
-
* This is horrible, should be cleaned up at some point.
|
59 |
-
*/
|
60 |
-
global $wpms_options;
|
61 |
-
$wpms_options = array(
|
62 |
-
'mail_from' => '',
|
63 |
-
'mail_from_name' => '',
|
64 |
-
'mailer' => 'smtp',
|
65 |
-
'mail_set_return_path' => 'false',
|
66 |
-
'smtp_host' => 'localhost',
|
67 |
-
'smtp_port' => '25',
|
68 |
-
'smtp_ssl' => 'none',
|
69 |
-
'smtp_auth' => false,
|
70 |
-
'smtp_user' => '',
|
71 |
-
'smtp_pass' => '',
|
72 |
-
'pepipost_user' => '',
|
73 |
-
'pepipost_pass' => '',
|
74 |
-
'pepipost_port' => '2525',
|
75 |
-
'pepipost_ssl' => 'none',
|
76 |
-
'wp_mail_smtp_am_notifications_hidden' => '',
|
77 |
-
);
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Activation function. This function creates the required options and defaults.
|
81 |
-
*/
|
82 |
-
if ( ! function_exists( 'wp_mail_smtp_activate' ) ) :
|
83 |
-
/**
|
84 |
-
* What to do on plugin activation.
|
85 |
-
*/
|
86 |
-
function wp_mail_smtp_activate() {
|
87 |
-
|
88 |
-
global $wpms_options;
|
89 |
-
|
90 |
-
// Create the required options...
|
91 |
-
foreach ( $wpms_options as $name => $val ) {
|
92 |
-
add_option( $name, $val );
|
93 |
-
}
|
94 |
-
}
|
95 |
-
endif;
|
96 |
-
|
97 |
-
if ( ! function_exists( 'wp_mail_smtp_whitelist_options' ) ) :
|
98 |
-
/**
|
99 |
-
* Whitelist plugin options.
|
100 |
-
*
|
101 |
-
* @param array $whitelist_options
|
102 |
-
*
|
103 |
-
* @return mixed
|
104 |
-
*/
|
105 |
-
function wp_mail_smtp_whitelist_options( $whitelist_options ) {
|
106 |
-
|
107 |
-
global $wpms_options;
|
108 |
-
|
109 |
-
// Add our options to the array.
|
110 |
-
$whitelist_options['email'] = array_keys( $wpms_options );
|
111 |
-
|
112 |
-
return $whitelist_options;
|
113 |
-
}
|
114 |
-
endif;
|
115 |
-
|
116 |
-
/**
|
117 |
-
* To avoid any (very unlikely) clashes, check if the function already exists.
|
118 |
-
*/
|
119 |
-
if ( ! function_exists( 'phpmailer_init_smtp' ) ) :
|
120 |
-
/**
|
121 |
-
* This code is copied, from wp-includes/pluggable.php as at version 2.2.2.
|
122 |
-
*
|
123 |
-
* @param PHPMailer $phpmailer It's passed by reference, so no need to return anything.
|
124 |
-
*/
|
125 |
-
function phpmailer_init_smtp( $phpmailer ) {
|
126 |
-
/*
|
127 |
-
* If constants are defined, apply them.
|
128 |
-
* We should have defined all required constants before using them.
|
129 |
-
*/
|
130 |
-
if (
|
131 |
-
defined( 'WPMS_ON' ) && WPMS_ON &&
|
132 |
-
defined( 'WPMS_MAILER' )
|
133 |
-
) {
|
134 |
-
$phpmailer->Mailer = WPMS_MAILER;
|
135 |
-
|
136 |
-
if ( defined( 'WPMS_SET_RETURN_PATH' ) && WPMS_SET_RETURN_PATH ) {
|
137 |
-
$phpmailer->Sender = $phpmailer->From;
|
138 |
-
}
|
139 |
-
|
140 |
-
if (
|
141 |
-
WPMS_MAILER === 'smtp' &&
|
142 |
-
defined( 'WPMS_SSL' ) &&
|
143 |
-
defined( 'WPMS_SMTP_HOST' ) &&
|
144 |
-
defined( 'WPMS_SMTP_PORT' )
|
145 |
-
) {
|
146 |
-
$phpmailer->SMTPSecure = WPMS_SSL;
|
147 |
-
$phpmailer->Host = WPMS_SMTP_HOST;
|
148 |
-
$phpmailer->Port = WPMS_SMTP_PORT;
|
149 |
-
|
150 |
-
if (
|
151 |
-
defined( 'WPMS_SMTP_AUTH' ) && WPMS_SMTP_AUTH &&
|
152 |
-
defined( 'WPMS_SMTP_USER' ) &&
|
153 |
-
defined( 'WPMS_SMTP_PASS' )
|
154 |
-
) {
|
155 |
-
$phpmailer->SMTPAuth = true;
|
156 |
-
$phpmailer->Username = WPMS_SMTP_USER;
|
157 |
-
$phpmailer->Password = WPMS_SMTP_PASS;
|
158 |
-
}
|
159 |
-
}
|
160 |
-
} else {
|
161 |
-
$option_mailer = get_option( 'mailer' );
|
162 |
-
$option_smtp_host = get_option( 'smtp_host' );
|
163 |
-
$option_smtp_ssl = get_option( 'smtp_ssl' );
|
164 |
-
|
165 |
-
// Check that mailer is not blank, and if mailer=smtp, host is not blank.
|
166 |
-
if (
|
167 |
-
! $option_mailer ||
|
168 |
-
( 'smtp' === $option_mailer && ! $option_smtp_host )
|
169 |
-
) {
|
170 |
-
return;
|
171 |
-
}
|
172 |
-
|
173 |
-
// If the mailer is pepipost, make sure we have a username and password.
|
174 |
-
if ( 'pepipost' === $option_mailer && ( ! get_option( 'pepipost_user' ) && ! get_option( 'pepipost_pass' ) ) ) {
|
175 |
-
return;
|
176 |
-
}
|
177 |
-
|
178 |
-
// Set the mailer type as per config above, this overrides the already called isMail method.
|
179 |
-
$phpmailer->Mailer = $option_mailer;
|
180 |
-
|
181 |
-
// Set the Sender (return-path) if required.
|
182 |
-
if ( get_option( 'mail_set_return_path' ) ) {
|
183 |
-
$phpmailer->Sender = $phpmailer->From;
|
184 |
-
}
|
185 |
-
|
186 |
-
// Set the SMTPSecure value, if set to none, leave this blank.
|
187 |
-
$phpmailer->SMTPSecure = $option_smtp_ssl;
|
188 |
-
if ( 'none' === $option_smtp_ssl ) {
|
189 |
-
$phpmailer->SMTPSecure = '';
|
190 |
-
$phpmailer->SMTPAutoTLS = false;
|
191 |
-
}
|
192 |
-
|
193 |
-
// If we're sending via SMTP, set the host.
|
194 |
-
if ( 'smtp' === $option_mailer ) {
|
195 |
-
// Set the other options.
|
196 |
-
$phpmailer->Host = $option_smtp_host;
|
197 |
-
$phpmailer->Port = get_option( 'smtp_port' );
|
198 |
-
|
199 |
-
// If we're using smtp auth, set the username & password.
|
200 |
-
if ( get_option( 'smtp_auth' ) === 'true' ) {
|
201 |
-
$phpmailer->SMTPAuth = true;
|
202 |
-
$phpmailer->Username = get_option( 'smtp_user' );
|
203 |
-
$phpmailer->Password = get_option( 'smtp_pass' );
|
204 |
-
}
|
205 |
-
} elseif ( 'pepipost' === $option_mailer ) {
|
206 |
-
// Set the Pepipost settings.
|
207 |
-
$phpmailer->Mailer = 'smtp';
|
208 |
-
$phpmailer->Host = 'smtp.pepipost.com';
|
209 |
-
$phpmailer->Port = get_option( 'pepipost_port' );
|
210 |
-
$phpmailer->SMTPSecure = get_option( 'pepipost_ssl' ) === 'none' ? '' : get_option( 'pepipost_ssl' );
|
211 |
-
$phpmailer->SMTPAuth = true;
|
212 |
-
$phpmailer->Username = get_option( 'pepipost_user' );
|
213 |
-
$phpmailer->Password = get_option( 'pepipost_pass' );
|
214 |
-
}
|
215 |
-
}
|
216 |
-
|
217 |
-
// You can add your own options here, see the phpmailer documentation for more info: http://phpmailer.sourceforge.net/docs/.
|
218 |
-
/** @noinspection PhpUnusedLocalVariableInspection It's passed by reference. */
|
219 |
-
$phpmailer = apply_filters( 'wp_mail_smtp_custom_options', $phpmailer );
|
220 |
-
}
|
221 |
-
endif;
|
222 |
-
|
223 |
-
if ( ! function_exists( 'wp_mail_smtp_options_page' ) ) :
|
224 |
-
/**
|
225 |
-
* This function outputs the plugin options page.
|
226 |
-
*/
|
227 |
-
function wp_mail_smtp_options_page() {
|
228 |
-
|
229 |
-
global $phpmailer;
|
230 |
-
|
231 |
-
// Make sure the PHPMailer class has been instantiated
|
232 |
-
// (copied verbatim from wp-includes/pluggable.php)
|
233 |
-
// (Re)create it, if it's gone missing.
|
234 |
-
if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) {
|
235 |
-
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
236 |
-
$phpmailer = new PHPMailer( true );
|
237 |
-
}
|
238 |
-
|
239 |
-
// Send a test mail if necessary.
|
240 |
-
if (
|
241 |
-
isset( $_POST['wpms_action'] ) &&
|
242 |
-
esc_html__( 'Send Test', 'wp-mail-smtp' ) === sanitize_text_field( $_POST['wpms_action'] ) &&
|
243 |
-
is_email( $_POST['to'] )
|
244 |
-
) {
|
245 |
-
|
246 |
-
check_admin_referer( 'test-email' );
|
247 |
-
|
248 |
-
// Set up the mail variables.
|
249 |
-
$to = sanitize_text_field( $_POST['to'] );
|
250 |
-
/* translators: %s - email address where test mail will be sent to. */
|
251 |
-
$subject = 'WP Mail SMTP: ' . sprintf( esc_html__( 'Test mail to %s', 'wp-mail-smtp' ), $to );
|
252 |
-
$message = esc_html__( 'This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp-mail-smtp' );
|
253 |
-
|
254 |
-
// Set SMTPDebug level, default is 2 (commands + data + connection status).
|
255 |
-
$phpmailer->SMTPDebug = apply_filters( 'wp_mail_smtp_admin_test_email_smtp_debug', 2 );
|
256 |
-
|
257 |
-
// Start output buffering to grab smtp debugging output.
|
258 |
-
ob_start();
|
259 |
-
|
260 |
-
// Send the test mail.
|
261 |
-
$result = wp_mail( $to, $subject, $message );
|
262 |
-
|
263 |
-
// Grab the smtp debugging output.
|
264 |
-
$smtp_debug = ob_get_clean();
|
265 |
-
|
266 |
-
// Output the response.
|
267 |
-
?>
|
268 |
-
<div id="message" class="updated notice is-dismissible"><p><strong><?php esc_html_e( 'Test Message Sent', 'wp-mail-smtp' ); ?></strong></p>
|
269 |
-
<p><?php esc_html_e( 'The result was:', 'wp-mail-smtp' ); ?></p>
|
270 |
-
<pre><?php var_dump( $result ); ?></pre>
|
271 |
-
|
272 |
-
<p><?php esc_html_e( 'The full debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
|
273 |
-
<pre><?php print_r( $phpmailer ); ?></pre>
|
274 |
-
|
275 |
-
<p><?php esc_html_e( 'The SMTP debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
|
276 |
-
<pre><?php echo $smtp_debug; ?></pre>
|
277 |
-
</div>
|
278 |
-
<?php
|
279 |
-
|
280 |
-
// Destroy $phpmailer so it doesn't cause issues later.
|
281 |
-
unset( $phpmailer );
|
282 |
-
}
|
283 |
-
|
284 |
-
?>
|
285 |
-
<div class="wrap">
|
286 |
-
<h2>
|
287 |
-
<?php esc_html_e( 'WP Mail SMTP Settings', 'wp-mail-smtp' ); ?>
|
288 |
-
</h2>
|
289 |
-
|
290 |
-
<form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
|
291 |
-
<?php wp_nonce_field( 'email-options' ); ?>
|
292 |
-
|
293 |
-
<table class="form-table">
|
294 |
-
<tr valign="top">
|
295 |
-
<th scope="row">
|
296 |
-
<label for="mail_from"><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></label>
|
297 |
-
</th>
|
298 |
-
<td>
|
299 |
-
<input name="mail_from" type="email" id="mail_from" value="<?php print( get_option( 'mail_from' ) ); ?>" size="40" class="regular-text"/>
|
300 |
-
|
301 |
-
<p class="description">
|
302 |
-
<?php
|
303 |
-
esc_html_e( 'You can specify the email address that emails should be sent from. If you leave this blank, the default email will be used.', 'wp-mail-smtp' );
|
304 |
-
if ( get_option( 'db_version' ) < 6124 ) {
|
305 |
-
print( '<br /><span style="color: red;">' );
|
306 |
-
_e( '<strong>Please Note:</strong> You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name<email@domain.com> in this field.', 'wp-mail-smtp' );
|
307 |
-
print( '</span>' );
|
308 |
-
}
|
309 |
-
?>
|
310 |
-
</p>
|
311 |
-
</td>
|
312 |
-
</tr>
|
313 |
-
<tr valign="top">
|
314 |
-
<th scope="row">
|
315 |
-
<label for="mail_from_name"><?php esc_html_e( 'From Name', 'wp-mail-smtp' ); ?></label>
|
316 |
-
</th>
|
317 |
-
<td>
|
318 |
-
<input name="mail_from_name" type="text" id="mail_from_name" value="<?php print( get_option( 'mail_from_name' ) ); ?>" size="40" class="regular-text"/>
|
319 |
-
|
320 |
-
<p class="description">
|
321 |
-
<?php esc_html_e( 'You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress.', 'wp-mail-smtp' ); ?>
|
322 |
-
</p>
|
323 |
-
</td>
|
324 |
-
</tr>
|
325 |
-
</table>
|
326 |
-
|
327 |
-
<table class="form-table">
|
328 |
-
<tr valign="top">
|
329 |
-
<th scope="row">
|
330 |
-
<?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?>
|
331 |
-
</th>
|
332 |
-
<td>
|
333 |
-
<fieldset>
|
334 |
-
<legend class="screen-reader-text">
|
335 |
-
<span><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></span>
|
336 |
-
</legend>
|
337 |
-
|
338 |
-
<p>
|
339 |
-
<input id="mailer_smtp" class="wpms_mailer" type="radio" name="mailer" value="smtp" <?php checked( 'smtp', get_option( 'mailer' ) ); ?> />
|
340 |
-
<label for="mailer_smtp"><?php esc_html_e( 'Send all WordPress emails via SMTP.', 'wp-mail-smtp' ); ?></label>
|
341 |
-
</p>
|
342 |
-
<p>
|
343 |
-
<input id="mailer_mail" class="wpms_mailer" type="radio" name="mailer" value="mail" <?php checked( 'mail', get_option( 'mailer' ) ); ?> />
|
344 |
-
<label for="mailer_mail"><?php esc_html_e( 'Use the PHP mail() function to send emails.', 'wp-mail-smtp' ); ?></label>
|
345 |
-
</p>
|
346 |
-
|
347 |
-
<?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
|
348 |
-
<p>
|
349 |
-
<input id="mailer_pepipost" class="wpms_mailer" type="radio" name="mailer" value="pepipost" <?php checked( 'pepipost', get_option( 'mailer' ) ); ?> />
|
350 |
-
<label for="mailer_pepipost"><?php esc_html_e( 'Use Pepipost SMTP to send emails.', 'wp-mail-smtp' ); ?></label>
|
351 |
-
</p>
|
352 |
-
<p class="description">
|
353 |
-
<?php
|
354 |
-
printf(
|
355 |
-
/* translators: %1$s - link start; %2$s - link end. */
|
356 |
-
esc_html__( 'Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s.', 'wp-mail-smtp' ),
|
357 |
-
'<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">',
|
358 |
-
'</a>'
|
359 |
-
);
|
360 |
-
?>
|
361 |
-
</p>
|
362 |
-
<?php endif; ?>
|
363 |
-
</fieldset>
|
364 |
-
</td>
|
365 |
-
</tr>
|
366 |
-
</table>
|
367 |
-
|
368 |
-
<table class="form-table">
|
369 |
-
<tr valign="top">
|
370 |
-
<th scope="row">
|
371 |
-
<?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?>
|
372 |
-
</th>
|
373 |
-
<td>
|
374 |
-
<fieldset>
|
375 |
-
<legend class="screen-reader-text">
|
376 |
-
<span><?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?></span>
|
377 |
-
</legend>
|
378 |
-
|
379 |
-
<label for="mail_set_return_path">
|
380 |
-
<input name="mail_set_return_path" type="checkbox" id="mail_set_return_path" value="true" <?php checked( 'true', get_option( 'mail_set_return_path' ) ); ?> />
|
381 |
-
<?php esc_html_e( 'Set the return-path to match the From Email', 'wp-mail-smtp' ); ?>
|
382 |
-
</label>
|
383 |
-
|
384 |
-
<p class="description">
|
385 |
-
<?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?>
|
386 |
-
</p>
|
387 |
-
</fieldset>
|
388 |
-
</td>
|
389 |
-
</tr>
|
390 |
-
</table>
|
391 |
-
|
392 |
-
<table class="form-table">
|
393 |
-
<tr valign="top">
|
394 |
-
<th scope="row">
|
395 |
-
<?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?>
|
396 |
-
</th>
|
397 |
-
<td>
|
398 |
-
<fieldset>
|
399 |
-
<legend class="screen-reader-text">
|
400 |
-
<span><?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?></span>
|
401 |
-
</legend>
|
402 |
-
|
403 |
-
<label for="wp_mail_smtp_am_notifications_hidden">
|
404 |
-
<input name="wp_mail_smtp_am_notifications_hidden" type="checkbox" id="wp_mail_smtp_am_notifications_hidden" value="true" <?php checked( 'true', get_option( 'wp_mail_smtp_am_notifications_hidden' ) ); ?> />
|
405 |
-
<?php _e( 'Check this if you would like to hide plugin announcements and update details.', 'wp-mail-smtp' ); ?>
|
406 |
-
</label>
|
407 |
-
</fieldset>
|
408 |
-
</td>
|
409 |
-
</tr>
|
410 |
-
</table>
|
411 |
-
|
412 |
-
<p class="submit">
|
413 |
-
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
|
414 |
-
</p>
|
415 |
-
|
416 |
-
<div id="wpms_section_smtp" class="wpms_section">
|
417 |
-
<h3>
|
418 |
-
<?php esc_html_e( 'SMTP Options', 'wp-mail-smtp' ); ?>
|
419 |
-
</h3>
|
420 |
-
<p><?php esc_html_e( 'These options only apply if you have chosen to send mail by SMTP above.', 'wp-mail-smtp' ); ?></p>
|
421 |
-
|
422 |
-
<table class="form-table">
|
423 |
-
<tr valign="top">
|
424 |
-
<th scope="row">
|
425 |
-
<label for="smtp_host"><?php esc_html_e( 'SMTP Host', 'wp-mail-smtp' ); ?></label>
|
426 |
-
</th>
|
427 |
-
<td>
|
428 |
-
<input name="smtp_host" type="text" id="smtp_host" value="<?php print( get_option( 'smtp_host' ) ); ?>" size="40" class="regular-text"/>
|
429 |
-
</td>
|
430 |
-
</tr>
|
431 |
-
<tr valign="top">
|
432 |
-
<th scope="row">
|
433 |
-
<label for="smtp_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
|
434 |
-
</th>
|
435 |
-
<td>
|
436 |
-
<input name="smtp_port" type="text" id="smtp_port" value="<?php print( get_option( 'smtp_port' ) ); ?>" size="6" class="regular-text"/>
|
437 |
-
</td>
|
438 |
-
</tr>
|
439 |
-
<tr valign="top">
|
440 |
-
<th scope="row"><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?> </th>
|
441 |
-
<td>
|
442 |
-
<fieldset>
|
443 |
-
<legend class="screen-reader-text">
|
444 |
-
<span><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?></span>
|
445 |
-
</legend>
|
446 |
-
|
447 |
-
<input id="smtp_ssl_none" type="radio" name="smtp_ssl" value="none" <?php checked( 'none', get_option( 'smtp_ssl' ) ); ?> />
|
448 |
-
<label for="smtp_ssl_none">
|
449 |
-
<span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
|
450 |
-
</label><br/>
|
451 |
-
|
452 |
-
<input id="smtp_ssl_ssl" type="radio" name="smtp_ssl" value="ssl" <?php checked( 'ssl', get_option( 'smtp_ssl' ) ); ?> />
|
453 |
-
<label for="smtp_ssl_ssl">
|
454 |
-
<span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
|
455 |
-
</label><br/>
|
456 |
-
|
457 |
-
<input id="smtp_ssl_tls" type="radio" name="smtp_ssl" value="tls" <?php checked( 'tls', get_option( 'smtp_ssl' ) ); ?> />
|
458 |
-
<label for="smtp_ssl_tls">
|
459 |
-
<span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
|
460 |
-
</label>
|
461 |
-
|
462 |
-
<p class="description"><?php esc_html_e( 'TLS is not the same as STARTTLS. For most servers SSL is the recommended option.', 'wp-mail-smtp' ); ?></p>
|
463 |
-
</fieldset>
|
464 |
-
</td>
|
465 |
-
</tr>
|
466 |
-
<tr valign="top">
|
467 |
-
<th scope="row"><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?> </th>
|
468 |
-
<td>
|
469 |
-
<fieldset>
|
470 |
-
<legend class="screen-reader-text">
|
471 |
-
<span><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?></span>
|
472 |
-
</legend>
|
473 |
-
|
474 |
-
<input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked( 'false', get_option( 'smtp_auth' ) ); ?> />
|
475 |
-
<label for="smtp_auth_false">
|
476 |
-
<span><?php esc_html_e( 'No: Do not use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
|
477 |
-
</label><br/>
|
478 |
-
|
479 |
-
<input id="smtp_auth_true" type="radio" name="smtp_auth" value="true" <?php checked( 'true', get_option( 'smtp_auth' ) ); ?> />
|
480 |
-
<label for="smtp_auth_true">
|
481 |
-
<span><?php esc_html_e( 'Yes: Use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
|
482 |
-
</label><br/>
|
483 |
-
|
484 |
-
<p class="description">
|
485 |
-
<?php esc_html_e( 'If this is set to no, the values below are ignored.', 'wp-mail-smtp' ); ?>
|
486 |
-
</p>
|
487 |
-
</fieldset>
|
488 |
-
</td>
|
489 |
-
</tr>
|
490 |
-
<tr valign="top">
|
491 |
-
<th scope="row">
|
492 |
-
<label for="smtp_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
|
493 |
-
</th>
|
494 |
-
<td>
|
495 |
-
<input name="smtp_user" type="text" id="smtp_user" value="<?php print( get_option( 'smtp_user' ) ); ?>" size="40" class="code" autocomplete="off"/>
|
496 |
-
</td>
|
497 |
-
</tr>
|
498 |
-
<tr valign="top">
|
499 |
-
<th scope="row">
|
500 |
-
<label for="smtp_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
|
501 |
-
</th>
|
502 |
-
<td>
|
503 |
-
<input name="smtp_pass" type="password" id="smtp_pass" value="<?php print( get_option( 'smtp_pass' ) ); ?>" size="40" class="code" autocomplete="off"/>
|
504 |
-
|
505 |
-
<p class="description">
|
506 |
-
<?php esc_html_e( 'This is in plain text because it must not be stored encrypted.', 'wp-mail-smtp' ); ?>
|
507 |
-
</p>
|
508 |
-
</td>
|
509 |
-
</tr>
|
510 |
-
</table>
|
511 |
-
|
512 |
-
<p class="submit">
|
513 |
-
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
|
514 |
-
</p>
|
515 |
-
</div><!-- #wpms_section_smtp -->
|
516 |
-
|
517 |
-
<?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
|
518 |
-
<div id="wpms_section_pepipost" class="wpms_section">
|
519 |
-
<h3>
|
520 |
-
<?php esc_html_e( 'Pepipost SMTP Options', 'wp-mail-smtp' ); ?>
|
521 |
-
</h3>
|
522 |
-
<p>
|
523 |
-
<?php
|
524 |
-
printf(
|
525 |
-
/* translators: %s - Pepipost registration URL. */
|
526 |
-
esc_html__( 'You need to signup on %s to get the SMTP username/password.', 'wp-mail-smtp' ),
|
527 |
-
'<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">Pepipost</a>',
|
528 |
-
''
|
529 |
-
);
|
530 |
-
?>
|
531 |
-
</p>
|
532 |
-
<table class="form-table">
|
533 |
-
<tr valign="top">
|
534 |
-
<th scope="row">
|
535 |
-
<label for="pepipost_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
|
536 |
-
</th>
|
537 |
-
<td>
|
538 |
-
<input name="pepipost_user" type="text" id="pepipost_user" value="<?php print( get_option( 'pepipost_user' ) ); ?>" size="40" class="code"/>
|
539 |
-
</td>
|
540 |
-
</tr>
|
541 |
-
<tr valign="top">
|
542 |
-
<th scope="row">
|
543 |
-
<label for="pepipost_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
|
544 |
-
</th>
|
545 |
-
<td>
|
546 |
-
<input name="pepipost_pass" type="text" id="pepipost_pass" value="<?php print( get_option( 'pepipost_pass' ) ); ?>" size="40" class="code"/>
|
547 |
-
</td>
|
548 |
-
</tr>
|
549 |
-
<tr valign="top">
|
550 |
-
<th scope="row">
|
551 |
-
<label for="pepipost_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
|
552 |
-
</th>
|
553 |
-
<td>
|
554 |
-
<input name="pepipost_port" type="text" id="pepipost_port" value="<?php print( get_option( 'pepipost_port' ) ); ?>" size="6" class="regular-text"/>
|
555 |
-
</td>
|
556 |
-
</tr>
|
557 |
-
<tr valign="top">
|
558 |
-
<th scope="row">
|
559 |
-
<?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
|
560 |
-
</th>
|
561 |
-
<td>
|
562 |
-
<fieldset>
|
563 |
-
<legend class="screen-reader-text">
|
564 |
-
<span>
|
565 |
-
<?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
|
566 |
-
</span>
|
567 |
-
</legend>
|
568 |
-
|
569 |
-
<input id="pepipost_ssl_none" type="radio" name="pepipost_ssl" value="none" <?php checked( 'none', get_option( 'pepipost_ssl' ) ); ?> />
|
570 |
-
<label for="pepipost_ssl_none">
|
571 |
-
<span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
|
572 |
-
</label><br/>
|
573 |
-
|
574 |
-
<input id="pepipost_ssl_ssl" type="radio" name="pepipost_ssl" value="ssl" <?php checked( 'ssl', get_option( 'pepipost_ssl' ) ); ?> />
|
575 |
-
<label for="pepipost_ssl_ssl">
|
576 |
-
<span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
|
577 |
-
</label><br/>
|
578 |
-
|
579 |
-
<input id="pepipost_ssl_tls" type="radio" name="pepipost_ssl" value="tls" <?php checked( 'tls', get_option( 'pepipost_ssl' ) ); ?> />
|
580 |
-
<label for="pepipost_ssl_tls">
|
581 |
-
<span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
|
582 |
-
</label>
|
583 |
-
</fieldset>
|
584 |
-
</td>
|
585 |
-
</tr>
|
586 |
-
</table>
|
587 |
-
|
588 |
-
<p class="submit">
|
589 |
-
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
|
590 |
-
</p>
|
591 |
-
</div><!-- #wpms_section_pepipost -->
|
592 |
-
<?php endif; ?>
|
593 |
-
|
594 |
-
<input type="hidden" name="action" value="update"/>
|
595 |
-
<input type="hidden" name="option_page" value="email">
|
596 |
-
</form>
|
597 |
-
|
598 |
-
<h3><?php esc_html_e( 'Send a Test Email', 'wp-mail-smtp' ); ?></h3>
|
599 |
-
|
600 |
-
<form method="POST" action="">
|
601 |
-
<?php wp_nonce_field( 'test-email' ); ?>
|
602 |
-
|
603 |
-
<table class="form-table">
|
604 |
-
<tr valign="top">
|
605 |
-
<th scope="row">
|
606 |
-
<label for="to"><?php esc_html_e( 'To', 'wp-mail-smtp' ); ?></label>
|
607 |
-
</th>
|
608 |
-
<td>
|
609 |
-
<input name="to" type="email" id="to" value="" size="40" class="code"/>
|
610 |
-
<p class="description"><?php esc_html_e( 'Type an email address here and then click Send Test to generate a test email.', 'wp-mail-smtp' ); ?></p>
|
611 |
-
</td>
|
612 |
-
</tr>
|
613 |
-
</table>
|
614 |
-
|
615 |
-
<p class="submit">
|
616 |
-
<input type="submit" name="wpms_action" id="wpms_action" class="button-primary" value="<?php esc_attr_e( 'Send Test', 'wp-mail-smtp' ); ?>"/>
|
617 |
-
</p>
|
618 |
-
</form>
|
619 |
-
|
620 |
-
<script type="text/javascript">
|
621 |
-
/* globals jQuery */
|
622 |
-
var wpmsOnMailerChange = function ( mailer ) {
|
623 |
-
// Hide all the mailer forms.
|
624 |
-
jQuery( '.wpms_section' ).hide();
|
625 |
-
// Show the target mailer form.
|
626 |
-
jQuery( '#wpms_section_' + mailer ).show();
|
627 |
-
};
|
628 |
-
jQuery( document ).ready( function () {
|
629 |
-
// Call wpmsOnMailerChange() on startup with the current mailer.
|
630 |
-
wpmsOnMailerChange( jQuery( 'input.wpms_mailer:checked' ).val() );
|
631 |
-
|
632 |
-
// Watch the mailer for any changes
|
633 |
-
jQuery( 'input.wpms_mailer' ).on( 'change', function ( e ) {
|
634 |
-
// Call the wpmsOnMailerChange() handler, passing the value of the newly selected mailer.
|
635 |
-
wpmsOnMailerChange( jQuery( e.target ).val() );
|
636 |
-
} );
|
637 |
-
} );
|
638 |
-
</script>
|
639 |
-
|
640 |
-
</div>
|
641 |
-
<?php
|
642 |
-
} // End of wp_mail_smtp_options_page() function definition.
|
643 |
-
endif;
|
644 |
-
|
645 |
-
if ( ! function_exists( 'wp_mail_smtp_menus' ) ) :
|
646 |
-
/**
|
647 |
-
* This function adds the required page (only 1 at the moment).
|
648 |
-
*/
|
649 |
-
function wp_mail_smtp_menus() {
|
650 |
-
|
651 |
-
if ( function_exists( 'add_submenu_page' ) ) {
|
652 |
-
add_options_page( esc_html__( 'WP Mail SMTP Settings', 'wp-mail-smtp' ), esc_html__( 'WP Mail SMTP', 'wp-mail-smtp' ), 'manage_options', __FILE__, 'wp_mail_smtp_options_page' );
|
653 |
-
}
|
654 |
-
} // End of wp_mail_smtp_menus() function definition.
|
655 |
-
endif;
|
656 |
-
|
657 |
-
if ( ! function_exists( 'wp_mail_smtp_mail_from' ) ) :
|
658 |
-
/**
|
659 |
-
* This function sets the from email value.
|
660 |
-
*
|
661 |
-
* @param string $orig
|
662 |
-
*
|
663 |
-
* @return string
|
664 |
-
*/
|
665 |
-
function wp_mail_smtp_mail_from( $orig ) {
|
666 |
-
/*
|
667 |
-
* This is copied from pluggable.php lines 348-354 as at revision 10150
|
668 |
-
* http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348.
|
669 |
-
*/
|
670 |
-
|
671 |
-
// In case of CLI we don't have SERVER_NAME, so use host name instead, may be not a domain name.
|
672 |
-
$server_name = ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
|
673 |
-
|
674 |
-
// Get the site domain and get rid of www.
|
675 |
-
$sitename = strtolower( $server_name );
|
676 |
-
if ( substr( $sitename, 0, 4 ) === 'www.' ) {
|
677 |
-
$sitename = substr( $sitename, 4 );
|
678 |
-
}
|
679 |
-
|
680 |
-
$default_from = 'wordpress@' . $sitename;
|
681 |
-
|
682 |
-
/*
|
683 |
-
* End of copied code.
|
684 |
-
*/
|
685 |
-
|
686 |
-
// If the from email is not the default, return it unchanged.
|
687 |
-
if ( $orig !== $default_from ) {
|
688 |
-
return $orig;
|
689 |
-
}
|
690 |
-
|
691 |
-
if (
|
692 |
-
defined( 'WPMS_ON' ) && WPMS_ON &&
|
693 |
-
defined( 'WPMS_MAIL_FROM' )
|
694 |
-
) {
|
695 |
-
$mail_from_email = WPMS_MAIL_FROM;
|
696 |
-
|
697 |
-
if ( ! empty( $mail_from_email ) ) {
|
698 |
-
return $mail_from_email;
|
699 |
-
}
|
700 |
-
}
|
701 |
-
|
702 |
-
if ( is_email( get_option( 'mail_from' ), false ) ) {
|
703 |
-
return get_option( 'mail_from' );
|
704 |
-
}
|
705 |
-
|
706 |
-
// If in doubt, return the original value.
|
707 |
-
return $orig;
|
708 |
-
} // End of wp_mail_smtp_mail_from() function definition.
|
709 |
-
endif;
|
710 |
-
|
711 |
-
if ( ! function_exists( 'wp_mail_smtp_mail_from_name' ) ) :
|
712 |
-
/**
|
713 |
-
* This function sets the from name value.
|
714 |
-
*
|
715 |
-
* @param string $orig
|
716 |
-
*
|
717 |
-
* @return string
|
718 |
-
*/
|
719 |
-
function wp_mail_smtp_mail_from_name( $orig ) {
|
720 |
-
|
721 |
-
// Only filter if the from name is the default.
|
722 |
-
if ( 'WordPress' === $orig ) {
|
723 |
-
if (
|
724 |
-
defined( 'WPMS_ON' ) && WPMS_ON &&
|
725 |
-
defined( 'WPMS_MAIL_FROM_NAME' )
|
726 |
-
) {
|
727 |
-
$mail_from_name = WPMS_MAIL_FROM_NAME;
|
728 |
-
|
729 |
-
if ( ! empty( $mail_from_name ) ) {
|
730 |
-
return $mail_from_name;
|
731 |
-
}
|
732 |
-
}
|
733 |
-
|
734 |
-
$from_name = get_option( 'mail_from_name' );
|
735 |
-
if ( ! empty( $from_name ) && is_string( $from_name ) ) {
|
736 |
-
return $from_name;
|
737 |
-
}
|
738 |
-
}
|
739 |
-
|
740 |
-
return $orig;
|
741 |
-
}
|
742 |
-
endif;
|
743 |
-
|
744 |
-
/**
|
745 |
-
* Add a link to Settings page of a plugin on Plugins page.
|
746 |
-
*
|
747 |
-
* @param array $links
|
748 |
-
* @param string $file
|
749 |
-
*
|
750 |
-
* @return mixed
|
751 |
-
*/
|
752 |
-
function wp_mail_plugin_action_links( $links, $file ) {
|
753 |
-
|
754 |
-
if ( plugin_basename( __FILE__ ) !== $file ) {
|
755 |
-
return $links;
|
756 |
-
}
|
757 |
-
|
758 |
-
$settings_link = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__( 'Settings', 'wp-mail-smtp' ) . '</a>';
|
759 |
-
|
760 |
-
array_unshift( $links, $settings_link );
|
761 |
-
|
762 |
-
return $links;
|
763 |
-
}
|
764 |
-
|
765 |
-
/**
|
766 |
-
* Awesome Motive Notifications.
|
767 |
-
*
|
768 |
-
* @since 0.11
|
769 |
-
*/
|
770 |
-
function wp_mail_smtp_am_notifications() {
|
771 |
-
|
772 |
-
$is_hidden = get_option( 'wp_mail_smtp_am_notifications_hidden', '' );
|
773 |
-
|
774 |
-
if ( 'true' === $is_hidden ) {
|
775 |
-
return;
|
776 |
-
}
|
777 |
-
|
778 |
-
if ( ! class_exists( 'WPMS_AM_Notification' ) ) {
|
779 |
-
require_once dirname( __FILE__ ) . '/class-wpms-am-notification.php';
|
780 |
-
}
|
781 |
-
|
782 |
-
new WPMS_AM_Notification( 'smtp', WPMS_PLUGIN_VER );
|
783 |
-
}
|
784 |
-
|
785 |
-
add_action( 'plugins_loaded', 'wp_mail_smtp_am_notifications' );
|
786 |
-
|
787 |
-
/**
|
788 |
-
* Check whether the site is using Pepipost or not.
|
789 |
-
*
|
790 |
-
* @since 0.11
|
791 |
-
*
|
792 |
-
* @return bool
|
793 |
-
*/
|
794 |
-
function wp_mail_smtp_is_pepipost_active() {
|
795 |
-
return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', 'pepipost' === get_option( 'mailer' ) );
|
796 |
-
}
|
797 |
-
|
798 |
-
/**
|
799 |
-
* Check the current PHP version and display a notice if on unsupported PHP.
|
800 |
-
*
|
801 |
-
* @since 0.11
|
802 |
-
*/
|
803 |
-
function wp_mail_smtp_check_php_version() {
|
804 |
-
|
805 |
-
// Display for PHP below 5.3.
|
806 |
-
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
|
807 |
-
return;
|
808 |
-
}
|
809 |
-
|
810 |
-
// Display for admins only.
|
811 |
-
if ( ! is_super_admin() ) {
|
812 |
-
return;
|
813 |
-
}
|
814 |
-
|
815 |
-
// Display on Dashboard page only.
|
816 |
-
if ( isset( $GLOBALS['pagenow'] ) && 'index.php' !== $GLOBALS['pagenow'] ) {
|
817 |
-
return;
|
818 |
-
}
|
819 |
-
|
820 |
-
echo '<div class="notice notice-error">' .
|
821 |
-
'<p>' .
|
822 |
-
sprintf(
|
823 |
-
/* translators: %1$s - WP Mail SMTP plugin name; %2$s - opening a link tag; %3$s - closing a link tag. */
|
824 |
-
esc_html__(
|
825 |
-
'Your site is running an outdated version of PHP that is no longer supported and may cause issues with %1$s. %2$sRead more%3$s for additional information.',
|
826 |
-
'wpforms'
|
827 |
-
),
|
828 |
-
'<strong>WP Mail SMTP</strong>',
|
829 |
-
'<a href="https://wpforms.com/docs/supported-php-version/" target="_blank">',
|
830 |
-
'</a>'
|
831 |
-
) .
|
832 |
-
'</p>' .
|
833 |
-
'</div>';
|
834 |
-
}
|
835 |
-
|
836 |
-
add_action( 'admin_notices', 'wp_mail_smtp_check_php_version' );
|
837 |
-
|
838 |
-
// Add an action on phpmailer_init.
|
839 |
-
add_action( 'phpmailer_init', 'phpmailer_init_smtp' );
|
840 |
-
|
841 |
-
if ( ! defined( 'WPMS_ON' ) || ! WPMS_ON ) {
|
842 |
-
// Whitelist our options.
|
843 |
-
add_filter( 'whitelist_options', 'wp_mail_smtp_whitelist_options' );
|
844 |
-
// Add the create pages options.
|
845 |
-
add_action( 'admin_menu', 'wp_mail_smtp_menus' );
|
846 |
-
// Add an activation hook for this plugin.
|
847 |
-
register_activation_hook( __FILE__, 'wp_mail_smtp_activate' );
|
848 |
-
// Adds "Settings" link to the Plugins page.
|
849 |
-
add_filter( 'plugin_action_links', 'wp_mail_plugin_action_links', 10, 2 );
|
850 |
-
}
|
851 |
-
|
852 |
-
// Add filters to replace the mail from name and email address.
|
853 |
-
add_filter( 'wp_mail_from', 'wp_mail_smtp_mail_from' );
|
854 |
-
add_filter( 'wp_mail_from_name', 'wp_mail_smtp_mail_from_name' );
|
855 |
-
|
856 |
-
load_plugin_textdomain( 'wp-mail-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: WP Mail SMTP
|
4 |
+
* Version: 1.2.0
|
5 |
+
* Plugin URI: https://wpforms.com/
|
6 |
+
* Description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage the settings.
|
7 |
+
* Author: WPForms
|
8 |
+
* Author URI: https://wpforms.com/
|
9 |
+
* Text Domain: wp-mail-smtp
|
10 |
+
* Domain Path: /languages
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @author WPForms
|
15 |
+
* @copyright WPForms, 2007-17, All Rights Reserved
|
16 |
+
* This code is released under the GPL licence version 3 or later, available here
|
17 |
+
* http://www.gnu.org/licenses/gpl.txt
|
18 |
+
*/
|
19 |
+
|
20 |
+
define( 'WPMS_PLUGIN_VER', '1.2.0' );
|
21 |
+
define( 'WPMS_PHP_VER', '5.3' );
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Setting options in wp-config.php
|
25 |
+
*
|
26 |
+
* Specifically aimed at WPMU users, you can set the options for this plugin as
|
27 |
+
* constants in wp-config.php. This disables the plugin's admin page and may
|
28 |
+
* improve performance very slightly. Copy the code below into wp-config.php.
|
29 |
+
*/
|
30 |
+
|
31 |
+
/*
|
32 |
+
define('WPMS_ON', true);
|
33 |
+
define('WPMS_MAIL_FROM', 'From Email');
|
34 |
+
define('WPMS_MAIL_FROM_NAME', 'From Name');
|
35 |
+
define('WPMS_MAILER', 'smtp'); // Possible values 'smtp', 'mail', or 'sendmail'
|
36 |
+
define('WPMS_SET_RETURN_PATH', 'false'); // Sets $phpmailer->Sender if true
|
37 |
+
define('WPMS_SMTP_HOST', 'localhost'); // The SMTP mail host
|
38 |
+
define('WPMS_SMTP_PORT', 25); // The SMTP server port number
|
39 |
+
define('WPMS_SSL', ''); // Possible values '', 'ssl', 'tls' - note TLS is not STARTTLS
|
40 |
+
define('WPMS_SMTP_AUTH', true); // True turns on SMTP authentication, false turns it off
|
41 |
+
define('WPMS_SMTP_USER', 'username'); // SMTP authentication username, only used if WPMS_SMTP_AUTH is true
|
42 |
+
define('WPMS_SMTP_PASS', 'password'); // SMTP authentication password, only used if WPMS_SMTP_AUTH is true
|
43 |
+
*/
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Newer PHP version 5.3+ will be handled a lot differently,
|
47 |
+
* with better code and newer logic.
|
48 |
+
*
|
49 |
+
* @since 1.0.0
|
50 |
+
*/
|
51 |
+
if ( version_compare( phpversion(), WPMS_PHP_VER, '>=' ) ) {
|
52 |
+
require_once dirname( __FILE__ ) . '/wp-mail-smtp.php';
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Array of options and their default values.
|
58 |
+
* This is horrible, should be cleaned up at some point.
|
59 |
+
*/
|
60 |
+
global $wpms_options;
|
61 |
+
$wpms_options = array(
|
62 |
+
'mail_from' => '',
|
63 |
+
'mail_from_name' => '',
|
64 |
+
'mailer' => 'smtp',
|
65 |
+
'mail_set_return_path' => 'false',
|
66 |
+
'smtp_host' => 'localhost',
|
67 |
+
'smtp_port' => '25',
|
68 |
+
'smtp_ssl' => 'none',
|
69 |
+
'smtp_auth' => false,
|
70 |
+
'smtp_user' => '',
|
71 |
+
'smtp_pass' => '',
|
72 |
+
'pepipost_user' => '',
|
73 |
+
'pepipost_pass' => '',
|
74 |
+
'pepipost_port' => '2525',
|
75 |
+
'pepipost_ssl' => 'none',
|
76 |
+
'wp_mail_smtp_am_notifications_hidden' => '',
|
77 |
+
);
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Activation function. This function creates the required options and defaults.
|
81 |
+
*/
|
82 |
+
if ( ! function_exists( 'wp_mail_smtp_activate' ) ) :
|
83 |
+
/**
|
84 |
+
* What to do on plugin activation.
|
85 |
+
*/
|
86 |
+
function wp_mail_smtp_activate() {
|
87 |
+
|
88 |
+
global $wpms_options;
|
89 |
+
|
90 |
+
// Create the required options...
|
91 |
+
foreach ( $wpms_options as $name => $val ) {
|
92 |
+
add_option( $name, $val );
|
93 |
+
}
|
94 |
+
}
|
95 |
+
endif;
|
96 |
+
|
97 |
+
if ( ! function_exists( 'wp_mail_smtp_whitelist_options' ) ) :
|
98 |
+
/**
|
99 |
+
* Whitelist plugin options.
|
100 |
+
*
|
101 |
+
* @param array $whitelist_options
|
102 |
+
*
|
103 |
+
* @return mixed
|
104 |
+
*/
|
105 |
+
function wp_mail_smtp_whitelist_options( $whitelist_options ) {
|
106 |
+
|
107 |
+
global $wpms_options;
|
108 |
+
|
109 |
+
// Add our options to the array.
|
110 |
+
$whitelist_options['email'] = array_keys( $wpms_options );
|
111 |
+
|
112 |
+
return $whitelist_options;
|
113 |
+
}
|
114 |
+
endif;
|
115 |
+
|
116 |
+
/**
|
117 |
+
* To avoid any (very unlikely) clashes, check if the function already exists.
|
118 |
+
*/
|
119 |
+
if ( ! function_exists( 'phpmailer_init_smtp' ) ) :
|
120 |
+
/**
|
121 |
+
* This code is copied, from wp-includes/pluggable.php as at version 2.2.2.
|
122 |
+
*
|
123 |
+
* @param PHPMailer $phpmailer It's passed by reference, so no need to return anything.
|
124 |
+
*/
|
125 |
+
function phpmailer_init_smtp( $phpmailer ) {
|
126 |
+
/*
|
127 |
+
* If constants are defined, apply them.
|
128 |
+
* We should have defined all required constants before using them.
|
129 |
+
*/
|
130 |
+
if (
|
131 |
+
defined( 'WPMS_ON' ) && WPMS_ON &&
|
132 |
+
defined( 'WPMS_MAILER' )
|
133 |
+
) {
|
134 |
+
$phpmailer->Mailer = WPMS_MAILER;
|
135 |
+
|
136 |
+
if ( defined( 'WPMS_SET_RETURN_PATH' ) && WPMS_SET_RETURN_PATH ) {
|
137 |
+
$phpmailer->Sender = $phpmailer->From;
|
138 |
+
}
|
139 |
+
|
140 |
+
if (
|
141 |
+
WPMS_MAILER === 'smtp' &&
|
142 |
+
defined( 'WPMS_SSL' ) &&
|
143 |
+
defined( 'WPMS_SMTP_HOST' ) &&
|
144 |
+
defined( 'WPMS_SMTP_PORT' )
|
145 |
+
) {
|
146 |
+
$phpmailer->SMTPSecure = WPMS_SSL;
|
147 |
+
$phpmailer->Host = WPMS_SMTP_HOST;
|
148 |
+
$phpmailer->Port = WPMS_SMTP_PORT;
|
149 |
+
|
150 |
+
if (
|
151 |
+
defined( 'WPMS_SMTP_AUTH' ) && WPMS_SMTP_AUTH &&
|
152 |
+
defined( 'WPMS_SMTP_USER' ) &&
|
153 |
+
defined( 'WPMS_SMTP_PASS' )
|
154 |
+
) {
|
155 |
+
$phpmailer->SMTPAuth = true;
|
156 |
+
$phpmailer->Username = WPMS_SMTP_USER;
|
157 |
+
$phpmailer->Password = WPMS_SMTP_PASS;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
} else {
|
161 |
+
$option_mailer = get_option( 'mailer' );
|
162 |
+
$option_smtp_host = get_option( 'smtp_host' );
|
163 |
+
$option_smtp_ssl = get_option( 'smtp_ssl' );
|
164 |
+
|
165 |
+
// Check that mailer is not blank, and if mailer=smtp, host is not blank.
|
166 |
+
if (
|
167 |
+
! $option_mailer ||
|
168 |
+
( 'smtp' === $option_mailer && ! $option_smtp_host )
|
169 |
+
) {
|
170 |
+
return;
|
171 |
+
}
|
172 |
+
|
173 |
+
// If the mailer is pepipost, make sure we have a username and password.
|
174 |
+
if ( 'pepipost' === $option_mailer && ( ! get_option( 'pepipost_user' ) && ! get_option( 'pepipost_pass' ) ) ) {
|
175 |
+
return;
|
176 |
+
}
|
177 |
+
|
178 |
+
// Set the mailer type as per config above, this overrides the already called isMail method.
|
179 |
+
$phpmailer->Mailer = $option_mailer;
|
180 |
+
|
181 |
+
// Set the Sender (return-path) if required.
|
182 |
+
if ( get_option( 'mail_set_return_path' ) ) {
|
183 |
+
$phpmailer->Sender = $phpmailer->From;
|
184 |
+
}
|
185 |
+
|
186 |
+
// Set the SMTPSecure value, if set to none, leave this blank.
|
187 |
+
$phpmailer->SMTPSecure = $option_smtp_ssl;
|
188 |
+
if ( 'none' === $option_smtp_ssl ) {
|
189 |
+
$phpmailer->SMTPSecure = '';
|
190 |
+
$phpmailer->SMTPAutoTLS = false;
|
191 |
+
}
|
192 |
+
|
193 |
+
// If we're sending via SMTP, set the host.
|
194 |
+
if ( 'smtp' === $option_mailer ) {
|
195 |
+
// Set the other options.
|
196 |
+
$phpmailer->Host = $option_smtp_host;
|
197 |
+
$phpmailer->Port = get_option( 'smtp_port' );
|
198 |
+
|
199 |
+
// If we're using smtp auth, set the username & password.
|
200 |
+
if ( get_option( 'smtp_auth' ) === 'true' ) {
|
201 |
+
$phpmailer->SMTPAuth = true;
|
202 |
+
$phpmailer->Username = get_option( 'smtp_user' );
|
203 |
+
$phpmailer->Password = get_option( 'smtp_pass' );
|
204 |
+
}
|
205 |
+
} elseif ( 'pepipost' === $option_mailer ) {
|
206 |
+
// Set the Pepipost settings.
|
207 |
+
$phpmailer->Mailer = 'smtp';
|
208 |
+
$phpmailer->Host = 'smtp.pepipost.com';
|
209 |
+
$phpmailer->Port = get_option( 'pepipost_port' );
|
210 |
+
$phpmailer->SMTPSecure = get_option( 'pepipost_ssl' ) === 'none' ? '' : get_option( 'pepipost_ssl' );
|
211 |
+
$phpmailer->SMTPAuth = true;
|
212 |
+
$phpmailer->Username = get_option( 'pepipost_user' );
|
213 |
+
$phpmailer->Password = get_option( 'pepipost_pass' );
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
// You can add your own options here, see the phpmailer documentation for more info: http://phpmailer.sourceforge.net/docs/.
|
218 |
+
/** @noinspection PhpUnusedLocalVariableInspection It's passed by reference. */
|
219 |
+
$phpmailer = apply_filters( 'wp_mail_smtp_custom_options', $phpmailer );
|
220 |
+
}
|
221 |
+
endif;
|
222 |
+
|
223 |
+
if ( ! function_exists( 'wp_mail_smtp_options_page' ) ) :
|
224 |
+
/**
|
225 |
+
* This function outputs the plugin options page.
|
226 |
+
*/
|
227 |
+
function wp_mail_smtp_options_page() {
|
228 |
+
|
229 |
+
global $phpmailer;
|
230 |
+
|
231 |
+
// Make sure the PHPMailer class has been instantiated
|
232 |
+
// (copied verbatim from wp-includes/pluggable.php)
|
233 |
+
// (Re)create it, if it's gone missing.
|
234 |
+
if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) {
|
235 |
+
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
236 |
+
$phpmailer = new PHPMailer( true );
|
237 |
+
}
|
238 |
+
|
239 |
+
// Send a test mail if necessary.
|
240 |
+
if (
|
241 |
+
isset( $_POST['wpms_action'] ) &&
|
242 |
+
esc_html__( 'Send Test', 'wp-mail-smtp' ) === sanitize_text_field( $_POST['wpms_action'] ) &&
|
243 |
+
is_email( $_POST['to'] )
|
244 |
+
) {
|
245 |
+
|
246 |
+
check_admin_referer( 'test-email' );
|
247 |
+
|
248 |
+
// Set up the mail variables.
|
249 |
+
$to = sanitize_text_field( $_POST['to'] );
|
250 |
+
/* translators: %s - email address where test mail will be sent to. */
|
251 |
+
$subject = 'WP Mail SMTP: ' . sprintf( esc_html__( 'Test mail to %s', 'wp-mail-smtp' ), $to );
|
252 |
+
$message = esc_html__( 'This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp-mail-smtp' );
|
253 |
+
|
254 |
+
// Set SMTPDebug level, default is 2 (commands + data + connection status).
|
255 |
+
$phpmailer->SMTPDebug = apply_filters( 'wp_mail_smtp_admin_test_email_smtp_debug', 2 );
|
256 |
+
|
257 |
+
// Start output buffering to grab smtp debugging output.
|
258 |
+
ob_start();
|
259 |
+
|
260 |
+
// Send the test mail.
|
261 |
+
$result = wp_mail( $to, $subject, $message );
|
262 |
+
|
263 |
+
// Grab the smtp debugging output.
|
264 |
+
$smtp_debug = ob_get_clean();
|
265 |
+
|
266 |
+
// Output the response.
|
267 |
+
?>
|
268 |
+
<div id="message" class="updated notice is-dismissible"><p><strong><?php esc_html_e( 'Test Message Sent', 'wp-mail-smtp' ); ?></strong></p>
|
269 |
+
<p><?php esc_html_e( 'The result was:', 'wp-mail-smtp' ); ?></p>
|
270 |
+
<pre><?php var_dump( $result ); ?></pre>
|
271 |
+
|
272 |
+
<p><?php esc_html_e( 'The full debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
|
273 |
+
<pre><?php print_r( $phpmailer ); ?></pre>
|
274 |
+
|
275 |
+
<p><?php esc_html_e( 'The SMTP debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
|
276 |
+
<pre><?php echo $smtp_debug; ?></pre>
|
277 |
+
</div>
|
278 |
+
<?php
|
279 |
+
|
280 |
+
// Destroy $phpmailer so it doesn't cause issues later.
|
281 |
+
unset( $phpmailer );
|
282 |
+
}
|
283 |
+
|
284 |
+
?>
|
285 |
+
<div class="wrap">
|
286 |
+
<h2>
|
287 |
+
<?php esc_html_e( 'WP Mail SMTP Settings', 'wp-mail-smtp' ); ?>
|
288 |
+
</h2>
|
289 |
+
|
290 |
+
<form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
|
291 |
+
<?php wp_nonce_field( 'email-options' ); ?>
|
292 |
+
|
293 |
+
<table class="form-table">
|
294 |
+
<tr valign="top">
|
295 |
+
<th scope="row">
|
296 |
+
<label for="mail_from"><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></label>
|
297 |
+
</th>
|
298 |
+
<td>
|
299 |
+
<input name="mail_from" type="email" id="mail_from" value="<?php print( get_option( 'mail_from' ) ); ?>" size="40" class="regular-text"/>
|
300 |
+
|
301 |
+
<p class="description">
|
302 |
+
<?php
|
303 |
+
esc_html_e( 'You can specify the email address that emails should be sent from. If you leave this blank, the default email will be used.', 'wp-mail-smtp' );
|
304 |
+
if ( get_option( 'db_version' ) < 6124 ) {
|
305 |
+
print( '<br /><span style="color: red;">' );
|
306 |
+
_e( '<strong>Please Note:</strong> You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name<email@domain.com> in this field.', 'wp-mail-smtp' );
|
307 |
+
print( '</span>' );
|
308 |
+
}
|
309 |
+
?>
|
310 |
+
</p>
|
311 |
+
</td>
|
312 |
+
</tr>
|
313 |
+
<tr valign="top">
|
314 |
+
<th scope="row">
|
315 |
+
<label for="mail_from_name"><?php esc_html_e( 'From Name', 'wp-mail-smtp' ); ?></label>
|
316 |
+
</th>
|
317 |
+
<td>
|
318 |
+
<input name="mail_from_name" type="text" id="mail_from_name" value="<?php print( get_option( 'mail_from_name' ) ); ?>" size="40" class="regular-text"/>
|
319 |
+
|
320 |
+
<p class="description">
|
321 |
+
<?php esc_html_e( 'You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress.', 'wp-mail-smtp' ); ?>
|
322 |
+
</p>
|
323 |
+
</td>
|
324 |
+
</tr>
|
325 |
+
</table>
|
326 |
+
|
327 |
+
<table class="form-table">
|
328 |
+
<tr valign="top">
|
329 |
+
<th scope="row">
|
330 |
+
<?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?>
|
331 |
+
</th>
|
332 |
+
<td>
|
333 |
+
<fieldset>
|
334 |
+
<legend class="screen-reader-text">
|
335 |
+
<span><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></span>
|
336 |
+
</legend>
|
337 |
+
|
338 |
+
<p>
|
339 |
+
<input id="mailer_smtp" class="wpms_mailer" type="radio" name="mailer" value="smtp" <?php checked( 'smtp', get_option( 'mailer' ) ); ?> />
|
340 |
+
<label for="mailer_smtp"><?php esc_html_e( 'Send all WordPress emails via SMTP.', 'wp-mail-smtp' ); ?></label>
|
341 |
+
</p>
|
342 |
+
<p>
|
343 |
+
<input id="mailer_mail" class="wpms_mailer" type="radio" name="mailer" value="mail" <?php checked( 'mail', get_option( 'mailer' ) ); ?> />
|
344 |
+
<label for="mailer_mail"><?php esc_html_e( 'Use the PHP mail() function to send emails.', 'wp-mail-smtp' ); ?></label>
|
345 |
+
</p>
|
346 |
+
|
347 |
+
<?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
|
348 |
+
<p>
|
349 |
+
<input id="mailer_pepipost" class="wpms_mailer" type="radio" name="mailer" value="pepipost" <?php checked( 'pepipost', get_option( 'mailer' ) ); ?> />
|
350 |
+
<label for="mailer_pepipost"><?php esc_html_e( 'Use Pepipost SMTP to send emails.', 'wp-mail-smtp' ); ?></label>
|
351 |
+
</p>
|
352 |
+
<p class="description">
|
353 |
+
<?php
|
354 |
+
printf(
|
355 |
+
/* translators: %1$s - link start; %2$s - link end. */
|
356 |
+
esc_html__( 'Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s.', 'wp-mail-smtp' ),
|
357 |
+
'<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">',
|
358 |
+
'</a>'
|
359 |
+
);
|
360 |
+
?>
|
361 |
+
</p>
|
362 |
+
<?php endif; ?>
|
363 |
+
</fieldset>
|
364 |
+
</td>
|
365 |
+
</tr>
|
366 |
+
</table>
|
367 |
+
|
368 |
+
<table class="form-table">
|
369 |
+
<tr valign="top">
|
370 |
+
<th scope="row">
|
371 |
+
<?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?>
|
372 |
+
</th>
|
373 |
+
<td>
|
374 |
+
<fieldset>
|
375 |
+
<legend class="screen-reader-text">
|
376 |
+
<span><?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?></span>
|
377 |
+
</legend>
|
378 |
+
|
379 |
+
<label for="mail_set_return_path">
|
380 |
+
<input name="mail_set_return_path" type="checkbox" id="mail_set_return_path" value="true" <?php checked( 'true', get_option( 'mail_set_return_path' ) ); ?> />
|
381 |
+
<?php esc_html_e( 'Set the return-path to match the From Email', 'wp-mail-smtp' ); ?>
|
382 |
+
</label>
|
383 |
+
|
384 |
+
<p class="description">
|
385 |
+
<?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?>
|
386 |
+
</p>
|
387 |
+
</fieldset>
|
388 |
+
</td>
|
389 |
+
</tr>
|
390 |
+
</table>
|
391 |
+
|
392 |
+
<table class="form-table">
|
393 |
+
<tr valign="top">
|
394 |
+
<th scope="row">
|
395 |
+
<?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?>
|
396 |
+
</th>
|
397 |
+
<td>
|
398 |
+
<fieldset>
|
399 |
+
<legend class="screen-reader-text">
|
400 |
+
<span><?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?></span>
|
401 |
+
</legend>
|
402 |
+
|
403 |
+
<label for="wp_mail_smtp_am_notifications_hidden">
|
404 |
+
<input name="wp_mail_smtp_am_notifications_hidden" type="checkbox" id="wp_mail_smtp_am_notifications_hidden" value="true" <?php checked( 'true', get_option( 'wp_mail_smtp_am_notifications_hidden' ) ); ?> />
|
405 |
+
<?php _e( 'Check this if you would like to hide plugin announcements and update details.', 'wp-mail-smtp' ); ?>
|
406 |
+
</label>
|
407 |
+
</fieldset>
|
408 |
+
</td>
|
409 |
+
</tr>
|
410 |
+
</table>
|
411 |
+
|
412 |
+
<p class="submit">
|
413 |
+
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
|
414 |
+
</p>
|
415 |
+
|
416 |
+
<div id="wpms_section_smtp" class="wpms_section">
|
417 |
+
<h3>
|
418 |
+
<?php esc_html_e( 'SMTP Options', 'wp-mail-smtp' ); ?>
|
419 |
+
</h3>
|
420 |
+
<p><?php esc_html_e( 'These options only apply if you have chosen to send mail by SMTP above.', 'wp-mail-smtp' ); ?></p>
|
421 |
+
|
422 |
+
<table class="form-table">
|
423 |
+
<tr valign="top">
|
424 |
+
<th scope="row">
|
425 |
+
<label for="smtp_host"><?php esc_html_e( 'SMTP Host', 'wp-mail-smtp' ); ?></label>
|
426 |
+
</th>
|
427 |
+
<td>
|
428 |
+
<input name="smtp_host" type="text" id="smtp_host" value="<?php print( get_option( 'smtp_host' ) ); ?>" size="40" class="regular-text"/>
|
429 |
+
</td>
|
430 |
+
</tr>
|
431 |
+
<tr valign="top">
|
432 |
+
<th scope="row">
|
433 |
+
<label for="smtp_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
|
434 |
+
</th>
|
435 |
+
<td>
|
436 |
+
<input name="smtp_port" type="text" id="smtp_port" value="<?php print( get_option( 'smtp_port' ) ); ?>" size="6" class="regular-text"/>
|
437 |
+
</td>
|
438 |
+
</tr>
|
439 |
+
<tr valign="top">
|
440 |
+
<th scope="row"><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?> </th>
|
441 |
+
<td>
|
442 |
+
<fieldset>
|
443 |
+
<legend class="screen-reader-text">
|
444 |
+
<span><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?></span>
|
445 |
+
</legend>
|
446 |
+
|
447 |
+
<input id="smtp_ssl_none" type="radio" name="smtp_ssl" value="none" <?php checked( 'none', get_option( 'smtp_ssl' ) ); ?> />
|
448 |
+
<label for="smtp_ssl_none">
|
449 |
+
<span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
|
450 |
+
</label><br/>
|
451 |
+
|
452 |
+
<input id="smtp_ssl_ssl" type="radio" name="smtp_ssl" value="ssl" <?php checked( 'ssl', get_option( 'smtp_ssl' ) ); ?> />
|
453 |
+
<label for="smtp_ssl_ssl">
|
454 |
+
<span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
|
455 |
+
</label><br/>
|
456 |
+
|
457 |
+
<input id="smtp_ssl_tls" type="radio" name="smtp_ssl" value="tls" <?php checked( 'tls', get_option( 'smtp_ssl' ) ); ?> />
|
458 |
+
<label for="smtp_ssl_tls">
|
459 |
+
<span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
|
460 |
+
</label>
|
461 |
+
|
462 |
+
<p class="description"><?php esc_html_e( 'TLS is not the same as STARTTLS. For most servers SSL is the recommended option.', 'wp-mail-smtp' ); ?></p>
|
463 |
+
</fieldset>
|
464 |
+
</td>
|
465 |
+
</tr>
|
466 |
+
<tr valign="top">
|
467 |
+
<th scope="row"><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?> </th>
|
468 |
+
<td>
|
469 |
+
<fieldset>
|
470 |
+
<legend class="screen-reader-text">
|
471 |
+
<span><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?></span>
|
472 |
+
</legend>
|
473 |
+
|
474 |
+
<input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked( 'false', get_option( 'smtp_auth' ) ); ?> />
|
475 |
+
<label for="smtp_auth_false">
|
476 |
+
<span><?php esc_html_e( 'No: Do not use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
|
477 |
+
</label><br/>
|
478 |
+
|
479 |
+
<input id="smtp_auth_true" type="radio" name="smtp_auth" value="true" <?php checked( 'true', get_option( 'smtp_auth' ) ); ?> />
|
480 |
+
<label for="smtp_auth_true">
|
481 |
+
<span><?php esc_html_e( 'Yes: Use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
|
482 |
+
</label><br/>
|
483 |
+
|
484 |
+
<p class="description">
|
485 |
+
<?php esc_html_e( 'If this is set to no, the values below are ignored.', 'wp-mail-smtp' ); ?>
|
486 |
+
</p>
|
487 |
+
</fieldset>
|
488 |
+
</td>
|
489 |
+
</tr>
|
490 |
+
<tr valign="top">
|
491 |
+
<th scope="row">
|
492 |
+
<label for="smtp_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
|
493 |
+
</th>
|
494 |
+
<td>
|
495 |
+
<input name="smtp_user" type="text" id="smtp_user" value="<?php print( get_option( 'smtp_user' ) ); ?>" size="40" class="code" autocomplete="off"/>
|
496 |
+
</td>
|
497 |
+
</tr>
|
498 |
+
<tr valign="top">
|
499 |
+
<th scope="row">
|
500 |
+
<label for="smtp_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
|
501 |
+
</th>
|
502 |
+
<td>
|
503 |
+
<input name="smtp_pass" type="password" id="smtp_pass" value="<?php print( get_option( 'smtp_pass' ) ); ?>" size="40" class="code" autocomplete="off"/>
|
504 |
+
|
505 |
+
<p class="description">
|
506 |
+
<?php esc_html_e( 'This is in plain text because it must not be stored encrypted.', 'wp-mail-smtp' ); ?>
|
507 |
+
</p>
|
508 |
+
</td>
|
509 |
+
</tr>
|
510 |
+
</table>
|
511 |
+
|
512 |
+
<p class="submit">
|
513 |
+
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
|
514 |
+
</p>
|
515 |
+
</div><!-- #wpms_section_smtp -->
|
516 |
+
|
517 |
+
<?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
|
518 |
+
<div id="wpms_section_pepipost" class="wpms_section">
|
519 |
+
<h3>
|
520 |
+
<?php esc_html_e( 'Pepipost SMTP Options', 'wp-mail-smtp' ); ?>
|
521 |
+
</h3>
|
522 |
+
<p>
|
523 |
+
<?php
|
524 |
+
printf(
|
525 |
+
/* translators: %s - Pepipost registration URL. */
|
526 |
+
esc_html__( 'You need to signup on %s to get the SMTP username/password.', 'wp-mail-smtp' ),
|
527 |
+
'<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">Pepipost</a>',
|
528 |
+
''
|
529 |
+
);
|
530 |
+
?>
|
531 |
+
</p>
|
532 |
+
<table class="form-table">
|
533 |
+
<tr valign="top">
|
534 |
+
<th scope="row">
|
535 |
+
<label for="pepipost_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
|
536 |
+
</th>
|
537 |
+
<td>
|
538 |
+
<input name="pepipost_user" type="text" id="pepipost_user" value="<?php print( get_option( 'pepipost_user' ) ); ?>" size="40" class="code"/>
|
539 |
+
</td>
|
540 |
+
</tr>
|
541 |
+
<tr valign="top">
|
542 |
+
<th scope="row">
|
543 |
+
<label for="pepipost_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
|
544 |
+
</th>
|
545 |
+
<td>
|
546 |
+
<input name="pepipost_pass" type="text" id="pepipost_pass" value="<?php print( get_option( 'pepipost_pass' ) ); ?>" size="40" class="code"/>
|
547 |
+
</td>
|
548 |
+
</tr>
|
549 |
+
<tr valign="top">
|
550 |
+
<th scope="row">
|
551 |
+
<label for="pepipost_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
|
552 |
+
</th>
|
553 |
+
<td>
|
554 |
+
<input name="pepipost_port" type="text" id="pepipost_port" value="<?php print( get_option( 'pepipost_port' ) ); ?>" size="6" class="regular-text"/>
|
555 |
+
</td>
|
556 |
+
</tr>
|
557 |
+
<tr valign="top">
|
558 |
+
<th scope="row">
|
559 |
+
<?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
|
560 |
+
</th>
|
561 |
+
<td>
|
562 |
+
<fieldset>
|
563 |
+
<legend class="screen-reader-text">
|
564 |
+
<span>
|
565 |
+
<?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
|
566 |
+
</span>
|
567 |
+
</legend>
|
568 |
+
|
569 |
+
<input id="pepipost_ssl_none" type="radio" name="pepipost_ssl" value="none" <?php checked( 'none', get_option( 'pepipost_ssl' ) ); ?> />
|
570 |
+
<label for="pepipost_ssl_none">
|
571 |
+
<span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
|
572 |
+
</label><br/>
|
573 |
+
|
574 |
+
<input id="pepipost_ssl_ssl" type="radio" name="pepipost_ssl" value="ssl" <?php checked( 'ssl', get_option( 'pepipost_ssl' ) ); ?> />
|
575 |
+
<label for="pepipost_ssl_ssl">
|
576 |
+
<span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
|
577 |
+
</label><br/>
|
578 |
+
|
579 |
+
<input id="pepipost_ssl_tls" type="radio" name="pepipost_ssl" value="tls" <?php checked( 'tls', get_option( 'pepipost_ssl' ) ); ?> />
|
580 |
+
<label for="pepipost_ssl_tls">
|
581 |
+
<span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
|
582 |
+
</label>
|
583 |
+
</fieldset>
|
584 |
+
</td>
|
585 |
+
</tr>
|
586 |
+
</table>
|
587 |
+
|
588 |
+
<p class="submit">
|
589 |
+
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
|
590 |
+
</p>
|
591 |
+
</div><!-- #wpms_section_pepipost -->
|
592 |
+
<?php endif; ?>
|
593 |
+
|
594 |
+
<input type="hidden" name="action" value="update"/>
|
595 |
+
<input type="hidden" name="option_page" value="email">
|
596 |
+
</form>
|
597 |
+
|
598 |
+
<h3><?php esc_html_e( 'Send a Test Email', 'wp-mail-smtp' ); ?></h3>
|
599 |
+
|
600 |
+
<form method="POST" action="">
|
601 |
+
<?php wp_nonce_field( 'test-email' ); ?>
|
602 |
+
|
603 |
+
<table class="form-table">
|
604 |
+
<tr valign="top">
|
605 |
+
<th scope="row">
|
606 |
+
<label for="to"><?php esc_html_e( 'To', 'wp-mail-smtp' ); ?></label>
|
607 |
+
</th>
|
608 |
+
<td>
|
609 |
+
<input name="to" type="email" id="to" value="" size="40" class="code"/>
|
610 |
+
<p class="description"><?php esc_html_e( 'Type an email address here and then click Send Test to generate a test email.', 'wp-mail-smtp' ); ?></p>
|
611 |
+
</td>
|
612 |
+
</tr>
|
613 |
+
</table>
|
614 |
+
|
615 |
+
<p class="submit">
|
616 |
+
<input type="submit" name="wpms_action" id="wpms_action" class="button-primary" value="<?php esc_attr_e( 'Send Test', 'wp-mail-smtp' ); ?>"/>
|
617 |
+
</p>
|
618 |
+
</form>
|
619 |
+
|
620 |
+
<script type="text/javascript">
|
621 |
+
/* globals jQuery */
|
622 |
+
var wpmsOnMailerChange = function ( mailer ) {
|
623 |
+
// Hide all the mailer forms.
|
624 |
+
jQuery( '.wpms_section' ).hide();
|
625 |
+
// Show the target mailer form.
|
626 |
+
jQuery( '#wpms_section_' + mailer ).show();
|
627 |
+
};
|
628 |
+
jQuery( document ).ready( function () {
|
629 |
+
// Call wpmsOnMailerChange() on startup with the current mailer.
|
630 |
+
wpmsOnMailerChange( jQuery( 'input.wpms_mailer:checked' ).val() );
|
631 |
+
|
632 |
+
// Watch the mailer for any changes
|
633 |
+
jQuery( 'input.wpms_mailer' ).on( 'change', function ( e ) {
|
634 |
+
// Call the wpmsOnMailerChange() handler, passing the value of the newly selected mailer.
|
635 |
+
wpmsOnMailerChange( jQuery( e.target ).val() );
|
636 |
+
} );
|
637 |
+
} );
|
638 |
+
</script>
|
639 |
+
|
640 |
+
</div>
|
641 |
+
<?php
|
642 |
+
} // End of wp_mail_smtp_options_page() function definition.
|
643 |
+
endif;
|
644 |
+
|
645 |
+
if ( ! function_exists( 'wp_mail_smtp_menus' ) ) :
|
646 |
+
/**
|
647 |
+
* This function adds the required page (only 1 at the moment).
|
648 |
+
*/
|
649 |
+
function wp_mail_smtp_menus() {
|
650 |
+
|
651 |
+
if ( function_exists( 'add_submenu_page' ) ) {
|
652 |
+
add_options_page( esc_html__( 'WP Mail SMTP Settings', 'wp-mail-smtp' ), esc_html__( 'WP Mail SMTP', 'wp-mail-smtp' ), 'manage_options', __FILE__, 'wp_mail_smtp_options_page' );
|
653 |
+
}
|
654 |
+
} // End of wp_mail_smtp_menus() function definition.
|
655 |
+
endif;
|
656 |
+
|
657 |
+
if ( ! function_exists( 'wp_mail_smtp_mail_from' ) ) :
|
658 |
+
/**
|
659 |
+
* This function sets the from email value.
|
660 |
+
*
|
661 |
+
* @param string $orig
|
662 |
+
*
|
663 |
+
* @return string
|
664 |
+
*/
|
665 |
+
function wp_mail_smtp_mail_from( $orig ) {
|
666 |
+
/*
|
667 |
+
* This is copied from pluggable.php lines 348-354 as at revision 10150
|
668 |
+
* http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348.
|
669 |
+
*/
|
670 |
+
|
671 |
+
// In case of CLI we don't have SERVER_NAME, so use host name instead, may be not a domain name.
|
672 |
+
$server_name = ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
|
673 |
+
|
674 |
+
// Get the site domain and get rid of www.
|
675 |
+
$sitename = strtolower( $server_name );
|
676 |
+
if ( substr( $sitename, 0, 4 ) === 'www.' ) {
|
677 |
+
$sitename = substr( $sitename, 4 );
|
678 |
+
}
|
679 |
+
|
680 |
+
$default_from = 'wordpress@' . $sitename;
|
681 |
+
|
682 |
+
/*
|
683 |
+
* End of copied code.
|
684 |
+
*/
|
685 |
+
|
686 |
+
// If the from email is not the default, return it unchanged.
|
687 |
+
if ( $orig !== $default_from ) {
|
688 |
+
return $orig;
|
689 |
+
}
|
690 |
+
|
691 |
+
if (
|
692 |
+
defined( 'WPMS_ON' ) && WPMS_ON &&
|
693 |
+
defined( 'WPMS_MAIL_FROM' )
|
694 |
+
) {
|
695 |
+
$mail_from_email = WPMS_MAIL_FROM;
|
696 |
+
|
697 |
+
if ( ! empty( $mail_from_email ) ) {
|
698 |
+
return $mail_from_email;
|
699 |
+
}
|
700 |
+
}
|
701 |
+
|
702 |
+
if ( is_email( get_option( 'mail_from' ), false ) ) {
|
703 |
+
return get_option( 'mail_from' );
|
704 |
+
}
|
705 |
+
|
706 |
+
// If in doubt, return the original value.
|
707 |
+
return $orig;
|
708 |
+
} // End of wp_mail_smtp_mail_from() function definition.
|
709 |
+
endif;
|
710 |
+
|
711 |
+
if ( ! function_exists( 'wp_mail_smtp_mail_from_name' ) ) :
|
712 |
+
/**
|
713 |
+
* This function sets the from name value.
|
714 |
+
*
|
715 |
+
* @param string $orig
|
716 |
+
*
|
717 |
+
* @return string
|
718 |
+
*/
|
719 |
+
function wp_mail_smtp_mail_from_name( $orig ) {
|
720 |
+
|
721 |
+
// Only filter if the from name is the default.
|
722 |
+
if ( 'WordPress' === $orig ) {
|
723 |
+
if (
|
724 |
+
defined( 'WPMS_ON' ) && WPMS_ON &&
|
725 |
+
defined( 'WPMS_MAIL_FROM_NAME' )
|
726 |
+
) {
|
727 |
+
$mail_from_name = WPMS_MAIL_FROM_NAME;
|
728 |
+
|
729 |
+
if ( ! empty( $mail_from_name ) ) {
|
730 |
+
return $mail_from_name;
|
731 |
+
}
|
732 |
+
}
|
733 |
+
|
734 |
+
$from_name = get_option( 'mail_from_name' );
|
735 |
+
if ( ! empty( $from_name ) && is_string( $from_name ) ) {
|
736 |
+
return $from_name;
|
737 |
+
}
|
738 |
+
}
|
739 |
+
|
740 |
+
return $orig;
|
741 |
+
}
|
742 |
+
endif;
|
743 |
+
|
744 |
+
/**
|
745 |
+
* Add a link to Settings page of a plugin on Plugins page.
|
746 |
+
*
|
747 |
+
* @param array $links
|
748 |
+
* @param string $file
|
749 |
+
*
|
750 |
+
* @return mixed
|
751 |
+
*/
|
752 |
+
function wp_mail_plugin_action_links( $links, $file ) {
|
753 |
+
|
754 |
+
if ( plugin_basename( __FILE__ ) !== $file ) {
|
755 |
+
return $links;
|
756 |
+
}
|
757 |
+
|
758 |
+
$settings_link = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__( 'Settings', 'wp-mail-smtp' ) . '</a>';
|
759 |
+
|
760 |
+
array_unshift( $links, $settings_link );
|
761 |
+
|
762 |
+
return $links;
|
763 |
+
}
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Awesome Motive Notifications.
|
767 |
+
*
|
768 |
+
* @since 0.11
|
769 |
+
*/
|
770 |
+
function wp_mail_smtp_am_notifications() {
|
771 |
+
|
772 |
+
$is_hidden = get_option( 'wp_mail_smtp_am_notifications_hidden', '' );
|
773 |
+
|
774 |
+
if ( 'true' === $is_hidden ) {
|
775 |
+
return;
|
776 |
+
}
|
777 |
+
|
778 |
+
if ( ! class_exists( 'WPMS_AM_Notification' ) ) {
|
779 |
+
require_once dirname( __FILE__ ) . '/class-wpms-am-notification.php';
|
780 |
+
}
|
781 |
+
|
782 |
+
new WPMS_AM_Notification( 'smtp', WPMS_PLUGIN_VER );
|
783 |
+
}
|
784 |
+
|
785 |
+
add_action( 'plugins_loaded', 'wp_mail_smtp_am_notifications' );
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Check whether the site is using Pepipost or not.
|
789 |
+
*
|
790 |
+
* @since 0.11
|
791 |
+
*
|
792 |
+
* @return bool
|
793 |
+
*/
|
794 |
+
function wp_mail_smtp_is_pepipost_active() {
|
795 |
+
return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', 'pepipost' === get_option( 'mailer' ) );
|
796 |
+
}
|
797 |
+
|
798 |
+
/**
|
799 |
+
* Check the current PHP version and display a notice if on unsupported PHP.
|
800 |
+
*
|
801 |
+
* @since 0.11
|
802 |
+
*/
|
803 |
+
function wp_mail_smtp_check_php_version() {
|
804 |
+
|
805 |
+
// Display for PHP below 5.3.
|
806 |
+
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
|
807 |
+
return;
|
808 |
+
}
|
809 |
+
|
810 |
+
// Display for admins only.
|
811 |
+
if ( ! is_super_admin() ) {
|
812 |
+
return;
|
813 |
+
}
|
814 |
+
|
815 |
+
// Display on Dashboard page only.
|
816 |
+
if ( isset( $GLOBALS['pagenow'] ) && 'index.php' !== $GLOBALS['pagenow'] ) {
|
817 |
+
return;
|
818 |
+
}
|
819 |
+
|
820 |
+
echo '<div class="notice notice-error">' .
|
821 |
+
'<p>' .
|
822 |
+
sprintf(
|
823 |
+
/* translators: %1$s - WP Mail SMTP plugin name; %2$s - opening a link tag; %3$s - closing a link tag. */
|
824 |
+
esc_html__(
|
825 |
+
'Your site is running an outdated version of PHP that is no longer supported and may cause issues with %1$s. %2$sRead more%3$s for additional information.',
|
826 |
+
'wpforms'
|
827 |
+
),
|
828 |
+
'<strong>WP Mail SMTP</strong>',
|
829 |
+
'<a href="https://wpforms.com/docs/supported-php-version/" target="_blank">',
|
830 |
+
'</a>'
|
831 |
+
) .
|
832 |
+
'</p>' .
|
833 |
+
'</div>';
|
834 |
+
}
|
835 |
+
|
836 |
+
add_action( 'admin_notices', 'wp_mail_smtp_check_php_version' );
|
837 |
+
|
838 |
+
// Add an action on phpmailer_init.
|
839 |
+
add_action( 'phpmailer_init', 'phpmailer_init_smtp' );
|
840 |
+
|
841 |
+
if ( ! defined( 'WPMS_ON' ) || ! WPMS_ON ) {
|
842 |
+
// Whitelist our options.
|
843 |
+
add_filter( 'whitelist_options', 'wp_mail_smtp_whitelist_options' );
|
844 |
+
// Add the create pages options.
|
845 |
+
add_action( 'admin_menu', 'wp_mail_smtp_menus' );
|
846 |
+
// Add an activation hook for this plugin.
|
847 |
+
register_activation_hook( __FILE__, 'wp_mail_smtp_activate' );
|
848 |
+
// Adds "Settings" link to the Plugins page.
|
849 |
+
add_filter( 'plugin_action_links', 'wp_mail_plugin_action_links', 10, 2 );
|
850 |
+
}
|
851 |
+
|
852 |
+
// Add filters to replace the mail from name and email address.
|
853 |
+
add_filter( 'wp_mail_from', 'wp_mail_smtp_mail_from' );
|
854 |
+
add_filter( 'wp_mail_from_name', 'wp_mail_smtp_mail_from_name' );
|
855 |
+
|
856 |
+
load_plugin_textdomain( 'wp-mail-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|