Skip to content

Commit 807cf77

Browse files
authored
Update class-socketlabs-mailer.php
1 parent 9081436 commit 807cf77

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

includes/class-socketlabs-mailer.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,23 @@ private function create_message(){
292292
* https://core.trac.wordpress.org/ticket/5007.
293293
*/
294294

295-
if ( $this->api_message["From"] == null ) {
295+
if ($this->api_message["From"] == null) {
296296
$from_name = 'WordPress';
297-
// Get the site domain and get rid of www.
298-
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
299-
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
300-
$sitename = substr( $sitename, 4 );
297+
$sitename = 'localhost';
298+
299+
// Check if SERVER_NAME is set
300+
if (isset($_SERVER['SERVER_NAME'])) {
301+
302+
// Set sitename to SERVER_NAME
303+
$sitename = $_SERVER['SERVER_NAME'];
304+
305+
// Make it lowercase
306+
$sitename = strtolower($sitename);
307+
308+
// Get rid of www. if it exists
309+
if (substr($sitename, 0, 4) == 'www.') {
310+
$sitename = substr($sitename, 4);
311+
}
301312
}
302313

303314
$from_email = 'wordpress@' . $sitename;
@@ -364,4 +375,4 @@ public function send(){
364375
));
365376
}
366377
}
367-
?>
378+
?>

0 commit comments

Comments
 (0)