fixing the from name, the previous function was sending emails to spam for some reason
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 18 Jul 2017 18:49:55 +0000 (14:49 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 18 Jul 2017 18:49:55 +0000 (14:49 -0400)
models/admin/events/list.php
models/front/events/frontAdd.php

index 8f1f4f8..b1e9b51 100644 (file)
@@ -926,7 +926,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
             $current_status = $event['fieldData']['status']['value'];
 
             if($to_email){
-                $message  = $siteName = get_bloginfo( 'name' ) . " Events<br><br>";
+                $message  = get_bloginfo( 'name' ) . " Events<br><br>";
                 $message .= "Event Name: " . $event_title . "<br>";
                 $message .= "Event Description: $event_intro<br>";
                 $message .= "Contact Name: $admin_name<br><br>";
index 5a2730e..35a6183 100644 (file)
@@ -273,6 +273,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         $confirmation_page_id = get_option('glm_members_database_option_event_confirmation_id');
         $redirect_url = get_permalink($confirmation_page_id);
         
+        
         // if form is submitted
         if ( isset( $_REQUEST['newEvent'] ) && $_REQUEST['newEvent'] == "Add Event" ) {
 
@@ -655,27 +656,28 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
                     }
 
                     // change the default wordpress from name when sending mail
-                    add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
-                    function yoursite_wp_mail_from_name($name) {
-                        $siteName = get_bloginfo('name');
-                        return $siteName;
-                    }
-                    // Send confirmation email, set the content type to allow html by using this filter
+//                    add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
+//                    function yoursite_wp_mail_from_name($name) {
+//                        $siteName = get_bloginfo('name');
+//                        return $siteName;
+//                    }
+//                    // Send confirmation email, set the content type to allow html by using this filter
                     add_filter( 'wp_mail_content_type', 'set_content_type' );
-
+                    
+                    $site_name = bloginfo('name');
                     $to      = $to_email;
                     $subject = 'Event Form Submission';
                     
                     $message = $htmlMessage;
                     $userBody = $userMessage;
 
-                    $header[] = 'From:' . $fromEmail;
-                    $header[] = 'Reply-To:' . $contactEmail;    
+                    $header[] = "From: $site_name <$fromEmail>";
+                    $header[] = 'Reply-To:' . $adminEmail;    
                     
                     wp_mail($to, $subject, $message, $header);
                     
                     // send a copy to the user submitting the email, using different headers and email template file
-                    $userHeader[] = 'From: ' . $fromEmail;
+                    $userHeader[] = "From: $site_name <$fromEmail>";
                     $userHeader[] = 'Reply-To: No-Reply@gaslightmedia.com';  
                     
                     if(wp_mail($adminEmail, $subject, $userBody, $userHeader)){