|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace BitApps\SMTP\Views; |
| 4 | + |
| 5 | +/** |
| 6 | + * The email template class for test emails. |
| 7 | + */ |
| 8 | +class EmailTemplate |
| 9 | +{ |
| 10 | + /** |
| 11 | + * Generate the test email content with Bit SMTP branding. |
| 12 | + * |
| 13 | + * @param array $data Additional data for the email |
| 14 | + * |
| 15 | + * @return string HTML content for the test email |
| 16 | + */ |
| 17 | + public static function getTemplate($data = []) |
| 18 | + { |
| 19 | + $title = isset($data['title']) ? $data['title'] : 'Bit SMTP Test Email'; |
| 20 | + $message = isset($data['message']) ? $data['message'] : 'This is a test email sent via Bit SMTP plugin to verify your email configuration.'; |
| 21 | + $siteName = isset($data['site_name']) ? $data['site_name'] : get_bloginfo('name'); |
| 22 | + $siteUrl = isset($data['site_url']) ? $data['site_url'] : home_url(); |
| 23 | + |
| 24 | + return ' |
| 25 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 26 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 27 | +<head> |
| 28 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 29 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 30 | + <title>' . esc_html($title) . '</title> |
| 31 | + <style type="text/css" rel="stylesheet"> |
| 32 | + /* Media Queries */ |
| 33 | + @media only screen and (max-width: 600px) { |
| 34 | + .email-body_inner, |
| 35 | + .email-footer { |
| 36 | + width: 100% !important; |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + @media only screen and (max-width: 500px) { |
| 41 | + .button { |
| 42 | + width: 100% !important; |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + /* Body */ |
| 47 | + body { |
| 48 | + margin: 0; |
| 49 | + padding: 0; |
| 50 | + font-family: Arial, sans-serif; |
| 51 | + -webkit-text-size-adjust: 100%; |
| 52 | + -ms-text-size-adjust: 100%; |
| 53 | + } |
| 54 | +
|
| 55 | + /* Email Body */ |
| 56 | + .email-body { |
| 57 | + background-color: #f5f5f5; |
| 58 | + width: 100%; |
| 59 | + padding: 20px 0; |
| 60 | + } |
| 61 | + |
| 62 | + .email-body_inner { |
| 63 | + background-color: #ffffff; |
| 64 | + margin: 0 auto; |
| 65 | + width: 570px; |
| 66 | + overflow: hidden; |
| 67 | + border-radius: 4px; |
| 68 | + box-shadow: 0 2px 8px rgba(0,0,0,0.1); |
| 69 | + } |
| 70 | + |
| 71 | + /* Email Footer */ |
| 72 | + .email-footer { |
| 73 | + margin: 0 auto; |
| 74 | + padding: 20px 0; |
| 75 | + text-align: center; |
| 76 | + width: 570px; |
| 77 | + } |
| 78 | + |
| 79 | + .email-footer p { |
| 80 | + color: #aeaeae; |
| 81 | + font-size: 12px; |
| 82 | + } |
| 83 | + |
| 84 | + /* Typography */ |
| 85 | + h1, |
| 86 | + h2, |
| 87 | + h3, |
| 88 | + h4, |
| 89 | + h5, |
| 90 | + h6 { |
| 91 | + font-family: Arial, sans-serif; |
| 92 | + color: #292929; |
| 93 | + margin-top: 0; |
| 94 | + margin-bottom: 12px; |
| 95 | + font-weight: bold; |
| 96 | + } |
| 97 | + |
| 98 | + h1 { |
| 99 | + font-size: 22px; |
| 100 | + line-height: 28px; |
| 101 | + } |
| 102 | + |
| 103 | + p { |
| 104 | + font-size: 16px; |
| 105 | + line-height: 22px; |
| 106 | + margin-top: 0; |
| 107 | + margin-bottom: 12px; |
| 108 | + color: #747474; |
| 109 | + } |
| 110 | + |
| 111 | + .sub { |
| 112 | + font-size: 13px; |
| 113 | + color: #aeaeae; |
| 114 | + margin-top: 10px; |
| 115 | + } |
| 116 | + |
| 117 | + /* Content */ |
| 118 | + .content-cell { |
| 119 | + padding: 45px; |
| 120 | + } |
| 121 | + |
| 122 | + .align-center { |
| 123 | + text-align: center; |
| 124 | + } |
| 125 | + |
| 126 | + .align-right { |
| 127 | + text-align: right; |
| 128 | + } |
| 129 | + |
| 130 | + .align-left { |
| 131 | + text-align: left; |
| 132 | + } |
| 133 | + |
| 134 | + .full-width { |
| 135 | + width: 100%; |
| 136 | + } |
| 137 | + |
| 138 | + .bit-smtp-logo { |
| 139 | + text-align: center; |
| 140 | + padding: 20px 0; |
| 141 | + } |
| 142 | + |
| 143 | + .bit-smtp-logo img { |
| 144 | + max-height: 60px; |
| 145 | + } |
| 146 | + |
| 147 | + /* Buttons */ |
| 148 | + .button { |
| 149 | + display: inline-block; |
| 150 | + padding: 10px 20px; |
| 151 | + border: 1px solid #4a6cf7; |
| 152 | + background-color: #4a6cf7; |
| 153 | + border-radius: 4px; |
| 154 | + text-decoration: none; |
| 155 | + color: #ffffff; |
| 156 | + font-size: 15px; |
| 157 | + text-align: center; |
| 158 | + cursor: pointer; |
| 159 | + } |
| 160 | + |
| 161 | + .button:hover { |
| 162 | + background-color: #3858e9; |
| 163 | + } |
| 164 | + |
| 165 | + .button--green { |
| 166 | + border-color: #5cb85c; |
| 167 | + background-color: #5cb85c; |
| 168 | + } |
| 169 | + |
| 170 | + .button--red { |
| 171 | + border-color: #d9534f; |
| 172 | + background-color: #d9534f; |
| 173 | + } |
| 174 | + |
| 175 | + /* Code Block */ |
| 176 | + .code { |
| 177 | + background-color: #f2f2f2; |
| 178 | + border-left: 4px solid #4a6cf7; |
| 179 | + padding: 12px 15px; |
| 180 | + font-family: monospace; |
| 181 | + font-size: 14px; |
| 182 | + margin: 15px 0; |
| 183 | + } |
| 184 | + |
| 185 | + /* Status */ |
| 186 | + .status { |
| 187 | + display: inline-block; |
| 188 | + padding: 6px 12px; |
| 189 | + border-radius: 4px; |
| 190 | + background-color: #d4edda; |
| 191 | + color: #155724; |
| 192 | + font-size: 14px; |
| 193 | + } |
| 194 | + </style> |
| 195 | +</head> |
| 196 | +<body> |
| 197 | + <table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0"> |
| 198 | + <tr> |
| 199 | + <td align="center"> |
| 200 | + <table class="email-content" width="100%" cellpadding="0" cellspacing="0"> |
| 201 | + <!-- Email Body --> |
| 202 | + <tr> |
| 203 | + <td class="email-body" width="100%"> |
| 204 | + <table class="email-body_inner" align="center" cellpadding="0" cellspacing="0"> |
| 205 | + <tr> |
| 206 | + <td class="content-cell"> |
| 207 | + <div class="bit-smtp-logo"> |
| 208 | + <!-- Bit SMTP SVG Logo --> |
| 209 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 124 124"> |
| 210 | + <rect width="124" height="124" fill="#d9d9d9" rx="30.38"/> |
| 211 | + <rect width="124" height="124" fill="#158af8" rx="30.38"/> |
| 212 | + <g filter="url(#c)"> |
| 213 | + <path fill="#fff" fill-rule="evenodd" d="m26 48.135 31.079 24.173a8.67 8.67 0 0 0 10.642 0L98.8 48.135V82.8c0 1.38-.548 2.702-1.524 3.676A5.2 5.2 0 0 1 93.6 88H31.2a5.2 5.2 0 0 1-3.676-1.524A5.2 5.2 0 0 1 26 82.8z" clip-rule="evenodd"/> |
| 214 | + </g> |
| 215 | + <g filter="url(#d)"> |
| 216 | + <path fill="#fff" fill-rule="evenodd" d="M98.8 41.236a5.2 5.2 0 0 1-2.007 4.069l-31.2 24.266a5.2 5.2 0 0 1-6.386 0l-31.2-24.266A5.2 5.2 0 0 1 26 41.235V41.2c0-1.38.548-2.702 1.524-3.676A5.2 5.2 0 0 1 31.2 36h62.4c1.38 0 2.702.548 3.676 1.524A5.2 5.2 0 0 1 98.8 41.2z" clip-rule="evenodd"/> |
| 217 | + </g> |
| 218 | +</svg> |
| 219 | + <h1>' . esc_html($title) . '</h1> |
| 220 | + </div> |
| 221 | + |
| 222 | + <p>Dear ' . esc_html(wp_get_current_user()->display_name ?: 'Administrator') . ',</p> |
| 223 | + |
| 224 | + <p>' . esc_html($message) . '</p> |
| 225 | + |
| 226 | + <div class="code"> |
| 227 | + <strong>Test Details:</strong><br> |
| 228 | + Date: ' . date_i18n(get_option('date_format') . ' ' . get_option('time_format')) . '<br> |
| 229 | + Site: <a href="' . esc_url($siteUrl) . '">' . esc_html($siteName) . '</a><br> |
| 230 | + Plugin: Bit SMTP |
| 231 | + </div> |
| 232 | + |
| 233 | + <p>Configuration Status: <span class="status">Working Properly</span></p> |
| 234 | + |
| 235 | + <p>If you received this email, your SMTP configuration is working correctly. You can now send emails reliably from your WordPress site using Bit SMTP.</p> |
| 236 | + |
| 237 | + <p>Best regards,<br> |
| 238 | + <strong>Bit Apps Team</strong></p> |
| 239 | + </td> |
| 240 | + </tr> |
| 241 | + </table> |
| 242 | + </td> |
| 243 | + </tr> |
| 244 | + |
| 245 | + <!-- Email Footer --> |
| 246 | + <tr> |
| 247 | + <td> |
| 248 | + <table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0"> |
| 249 | + <tr> |
| 250 | + <td class="content-cell" align="center"> |
| 251 | + <p class="sub align-center"> |
| 252 | + © ' . date('Y') . ' Bit SMTP Plugin. All rights reserved. |
| 253 | + </p> |
| 254 | + <p class="sub align-center"> |
| 255 | + This is an automated email sent from your WordPress site using the Bit SMTP plugin. |
| 256 | + </p> |
| 257 | + </td> |
| 258 | + </tr> |
| 259 | + </table> |
| 260 | + </td> |
| 261 | + </tr> |
| 262 | + </table> |
| 263 | + </td> |
| 264 | + </tr> |
| 265 | + </table> |
| 266 | +</body> |
| 267 | +</html>'; |
| 268 | + } |
| 269 | + |
| 270 | + /** |
| 271 | + * Get a plain text version of the test email |
| 272 | + * |
| 273 | + * @param array $data Additional data for the email |
| 274 | + * |
| 275 | + * @return string Plain text content for the test email |
| 276 | + */ |
| 277 | + public static function getPlainTextTemplate($data = []) |
| 278 | + { |
| 279 | + $title = isset($data['title']) ? $data['title'] : 'Bit SMTP Test Email'; |
| 280 | + $message = isset($data['message']) ? $data['message'] : 'This is a test email sent via Bit SMTP plugin to verify your email configuration.'; |
| 281 | + $siteName = isset($data['site_name']) ? $data['site_name'] : get_bloginfo('name'); |
| 282 | + $siteUrl = isset($data['site_url']) ? $data['site_url'] : home_url(); |
| 283 | + $currentUser = wp_get_current_user()->display_name ?: 'Administrator'; |
| 284 | + |
| 285 | + return " |
| 286 | +{$title} |
| 287 | +
|
| 288 | +Dear {$currentUser}, |
| 289 | +
|
| 290 | +{$message} |
| 291 | +
|
| 292 | +Test Details: |
| 293 | +Date: " . date_i18n(get_option('date_format') . ' ' . get_option('time_format')) . " |
| 294 | +Site: {$siteName} ({$siteUrl}) |
| 295 | +Plugin: Bit SMTP |
| 296 | +
|
| 297 | +Configuration Status: Working Properly |
| 298 | +
|
| 299 | +If you received this email, your SMTP configuration is working correctly. You can now send emails reliably from your WordPress site using Bit SMTP. |
| 300 | +
|
| 301 | +Best regards, |
| 302 | +Bit Apps Team |
| 303 | +
|
| 304 | +---------------------------------------- |
| 305 | +© " . date('Y') . ' Bit SMTP Plugin. All rights reserved. |
| 306 | +This is an automated email sent from your WordPress site using the Bit SMTP plugin. |
| 307 | +'; |
| 308 | + } |
| 309 | +} |
0 commit comments