PluginProbe
phpinfo() WP – Site Health, PHP Compatibility & Server Audit / 7.2.5
phpinfo() WP – Site Health, PHP Compatibility & Server Audit v7.2.5
7.2.7 7.2.6 7.2.5 7.2.4 7.2.3 7.2.0 7.2.1 7.2.2 7.1.0 7.0.3 7.0.4 7.0.5 trunk 6.0 7.0.0 7.0.1 7.0.2
phpinfo-wp / views / pro / mail.php

mail.php in phpinfo() WP – Site Health, PHP Compatibility & Server Audit 7.2.5, at views/pro/mail.php

176 lines 9.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') or die('Unauthorized Access');
3
4 if (!Phpinfo_WP_License::is_valid()) {
5 phpinfowp_render_feature_lock([
6 'feature' => 'Mail Deliverability Check',
7 'icon' => 'dashicons-email-alt',
8 'tagline' => 'Send a test email, verify SPF & DKIM records, and catch delivery problems before clients do.',
9 'previews' => [
10 'SPF record: <strong>—</strong>',
11 'DKIM: <strong>—</strong>',
12 'Test email result: <strong>—</strong>',
13 ],
14 ]);
15 return;
16 }
17
18 $test_result = null;
19 if (isset($_POST['phpinfowp_mail_test']) && check_admin_referer('phpinfowp_mail_nonce')) {
20 $to = sanitize_email($_POST['test_to'] ?? '');
21 $test_result = Phpinfo_WP_Mail_Check::send_test($to);
22 }
23
24 $audit = Phpinfo_WP_Mail_Check::audit();
25
26 $row = function($title, $ok, $value, $warning = null) {
27 $color = $ok ? '#00a32a' : '#d63638';
28 $dicon = $ok ? 'dashicons-yes-alt' : 'dashicons-dismiss';
29 ?>
30 <div class="phpinfowp-sec-row phpinfowp-mail-row" style="border-left-color:<?php echo $color; ?>">
31 <div class="phpinfowp-sec-row-icon"><span class="dashicons <?php echo $dicon; ?>" style="color:<?php echo $color; ?>"></span></div>
32 <div class="phpinfowp-sec-row-body">
33 <div class="phpinfowp-sec-row-title"><strong><?php echo esc_html($title); ?></strong></div>
34 <?php if ($value): ?>
35 <code class="phpinfowp-sec-row-value"><?php echo esc_html($value); ?></code>
36 <?php else: ?>
37 <span class="phpinfowp-sec-row-missing"><?php _e('not found', 'phpinfo-wp'); ?></span>
38 <?php endif; ?>
39 <?php if ($warning): ?>
40 <div class="phpinfowp-sec-row-note" style="color:#996800"><?php echo esc_html($warning); ?></div>
41 <?php endif; ?>
42 </div>
43 </div>
44 <?php
45 };
46 ?>
47
48 <div class="phpinfowp-pro-page">
49
50 <div class="phpinfowp-page-header">
51 <div>
52 <h1>Mail Deliverability <span class="phpinfowp-pro-badge"><?php _e('PRO', 'phpinfo-wp'); ?></span></h1>
53 <p class="phpinfowp-page-subtitle"><?php _e('SPF, DKIM, DMARC, and SMTP configuration audit', 'phpinfo-wp'); ?></p>
54 </div>
55 </div>
56
57 <?php if (!$audit): ?>
58 <div class="notice notice-error inline"><p><?php _e('Could not audit mail configuration.', 'phpinfo-wp'); ?></p></div>
59 <?php else: ?>
60
61 <!-- Summary card -->
62 <div class="phpinfowp-mail-summary">
63 <div>
64 <div class="phpinfowp-mail-summary-label"><?php _e('Sending from', 'phpinfo-wp'); ?></div>
65 <div class="phpinfowp-mail-summary-value"><?php echo esc_html($audit['from_email']); ?></div>
66 <div class="phpinfowp-mail-summary-sub">Domain: <code><?php echo esc_html($audit['domain']); ?></code></div>
67 </div>
68 <div>
69 <div class="phpinfowp-mail-summary-label"><?php _e('Mail method', 'phpinfo-wp'); ?></div>
70 <?php if ($audit['smtp_plugin']): ?>
71 <div class="phpinfowp-mail-summary-value" style="color:#00a32a"><?php echo esc_html($audit['smtp_plugin']); ?></div>
72 <div class="phpinfowp-mail-summary-sub"><?php _e('SMTP plugin active', 'phpinfo-wp'); ?></div>
73 <?php else: ?>
74 <div class="phpinfowp-mail-summary-value" style="color:#dba617"><?php _e('PHP mail()', 'phpinfo-wp'); ?></div>
75 <div class="phpinfowp-mail-summary-sub"><?php _e('Consider an SMTP plugin for deliverability', 'phpinfo-wp'); ?></div>
76 <?php endif; ?>
77 </div>
78 </div>
79
80 <!-- Routing Audit -->
81 <?php $routing_emails = Phpinfo_WP_Mail_Check::discover_routing_emails(); ?>
82 <?php if (!empty($routing_emails)): ?>
83 <h2 class="phpinfowp-section-heading" style="margin-top:24px"><?php _e('Email Routing Audit', 'phpinfo-wp'); ?></h2>
84 <p class="phpinfowp-page-subtitle" style="margin-bottom:16px"><?php _e('Discovered email addresses used for administration and contact forms.', 'phpinfo-wp'); ?></p>
85 <table class="widefat striped">
86 <thead>
87 <tr>
88 <th><?php _e('Source', 'phpinfo-wp'); ?></th>
89 <th><?php _e('Email Address', 'phpinfo-wp'); ?></th>
90 <th><?php _e('Domain MX', 'phpinfo-wp'); ?></th>
91 <th style="width:100px"><?php _e('Test', 'phpinfo-wp'); ?></th>
92 </tr>
93 </thead>
94 <tbody>
95 <?php foreach ($routing_emails as $re): ?>
96 <tr>
97 <td style="vertical-align:middle;font-weight:600;color:#1d2327"><?php echo esc_html($re['source']); ?></td>
98 <td style="vertical-align:middle"><code><?php echo esc_html($re['email']); ?></code></td>
99 <td style="vertical-align:middle">
100 <?php if ($re['mx_ok']): ?>
101 <span style="color:#00a32a"><span class="dashicons dashicons-yes-alt" style="vertical-align:middle;margin-right:2px"></span> Valid</span>
102 <?php else: ?>
103 <span style="color:#d63638;font-weight:600"><span class="dashicons dashicons-warning" style="vertical-align:middle;margin-right:2px"></span> No MX Records</span>
104 <?php endif; ?>
105 </td>
106 <td style="vertical-align:middle">
107 <form method="post" style="margin:0">
108 <?php wp_nonce_field('phpinfowp_mail_nonce'); ?>
109 <input type="hidden" name="test_to" value="<?php echo esc_attr($re['email']); ?>">
110 <button type="submit" name="phpinfowp_mail_test" value="1" class="button button-small"><?php _e('Send test', 'phpinfo-wp'); ?></button>
111 </form>
112 </td>
113 </tr>
114 <?php endforeach; ?>
115 </tbody>
116 </table>
117 <?php endif; ?>
118
119 <!-- DNS audit -->
120 <h2 class="phpinfowp-section-heading" style="margin-top:32px"><?php _e('DNS Records', 'phpinfo-wp'); ?></h2>
121 <div class="phpinfowp-sec-rows">
122 <?php $row('SPF (Sender Policy Framework)', $audit['spf']['present'], $audit['spf']['value'] ?? null, $audit['spf']['warning'] ?? null); ?>
123 <?php $row('DMARC', $audit['dmarc']['present'],$audit['dmarc']['value'] ?? null, $audit['dmarc']['warning'] ?? null); ?>
124
125 <?php if ($audit['mx']): ?>
126 <div class="phpinfowp-sec-row phpinfowp-mail-row" style="border-left-color:#00a32a">
127 <div class="phpinfowp-sec-row-icon"><span class="dashicons dashicons-yes-alt" style="color:#00a32a"></span></div>
128 <div class="phpinfowp-sec-row-body">
129 <div class="phpinfowp-sec-row-title"><strong><?php _e('MX records', 'phpinfo-wp'); ?></strong></div>
130 <?php foreach ($audit['mx'] as $mx): ?>
131 <code class="phpinfowp-sec-row-value"><?php echo (int)$mx['priority']; ?> &nbsp; <?php echo esc_html($mx['host']); ?></code><br>
132 <?php endforeach; ?>
133 </div>
134 </div>
135 <?php else: ?>
136 <div class="phpinfowp-sec-row phpinfowp-mail-row" style="border-left-color:#d63638">
137 <div class="phpinfowp-sec-row-icon"><span class="dashicons dashicons-dismiss" style="color:#d63638"></span></div>
138 <div class="phpinfowp-sec-row-body">
139 <div class="phpinfowp-sec-row-title"><strong><?php _e('MX records', 'phpinfo-wp'); ?></strong></div>
140 <span class="phpinfowp-sec-row-missing">no MX records found for <?php echo esc_html($audit['domain']); ?></span>
141 </div>
142 </div>
143 <?php endif; ?>
144
145 <div class="phpinfowp-sec-row phpinfowp-mail-row" style="border-left-color:#888">
146 <div class="phpinfowp-sec-row-icon"><span class="dashicons dashicons-info" style="color:#888"></span></div>
147 <div class="phpinfowp-sec-row-body">
148 <div class="phpinfowp-sec-row-title"><strong><?php _e('DKIM', 'phpinfo-wp'); ?></strong></div>
149 <div class="phpinfowp-sec-row-note">DKIM uses a selector-specific subdomain (e.g. <code>default._domainkey.<?php echo esc_html($audit['domain']); ?></code>). Verify with your SMTP provider selectors are not auto-detectable.</div>
150 </div>
151 </div>
152 </div>
153
154 <!-- Test email -->
155 <h2 class="phpinfowp-section-heading" style="margin-top:32px"><?php _e('Send Test Email', 'phpinfo-wp'); ?></h2>
156 <form method="post" class="phpinfowp-mail-test-form">
157 <?php wp_nonce_field('phpinfowp_mail_nonce'); ?>
158 <input type="email" name="test_to" placeholder="<?php echo esc_attr__('recipient@example.com', 'phpinfo-wp'); ?>" required class="regular-text">
159 <button type="submit" name="phpinfowp_mail_test" value="1" class="button button-primary">
160 <span class="dashicons dashicons-email" style="vertical-align:middle"></span> Send test
161 </button>
162 </form>
163
164 <?php if ($test_result): ?>
165 <div class="notice notice-<?php echo $test_result['ok'] ? 'success' : 'error'; ?> inline" style="margin-top:14px">
166 <?php if ($test_result['ok']): ?>
167 <p>Test email sent to <strong><?php echo esc_html($test_result['sent_to']); ?></strong> via <?php echo esc_html($test_result['method']); ?>. Check the inbox (and spam folder) within 60 seconds.</p>
168 <?php else: ?>
169 <p>Could not send: <strong><?php echo esc_html($test_result['error'] ?? implode('; ', $test_result['errors'])); ?></strong></p>
170 <?php endif; ?>
171 </div>
172 <?php endif; ?>
173
174 <?php endif; ?>
175 </div>
176