get_reply_address() public method

This controls the "Reply-To" field in the email. Typically, this will contain hash data for the connector to work out what incoming emails are replying to, but this cannot be assumed.
public get_reply_address ( WP_User $user ) : string | null
$user WP_User
return string | null Reply email address
Example #1
0
 public function send_mail($users, Falcon_Message $message)
 {
     $options = $message->get_options();
     $from = Falcon::get_from_address();
     $author = $message->get_author();
     $messages = array();
     foreach ($users as $user) {
         $data = array('from_email' => $from, 'to' => array(array('email' => $user->user_email, 'name' => $user->display_name)), 'subject' => $message->get_subject(), 'headers' => array('Reply-To' => $message->get_reply_address($user)));
         if ($author) {
             $data['from_name'] = $author;
         }
         if ($text = $message->get_text()) {
             $data['text'] = $text;
         }
         if ($html = $message->get_html()) {
             $data['html'] = $html;
         }
         // Set the message ID if we've got one
         if (!empty($options['message-id'])) {
             $data['headers']['Message-ID'] = $options['message-id'];
         }
         // If this is a reply, set the headers as needed
         if (!empty($options['in-reply-to'])) {
             $original = $options['in-reply-to'];
             if (is_array($original)) {
                 $original = isset($options['in-reply-to'][$user->ID]) ? $options['in-reply-to'][$user->ID] : null;
             }
             if (!empty($original)) {
                 $data['headers']['In-Reply-To'] = $original;
             }
         }
         if (!empty($options['references'])) {
             $references = implode(' ', $options['references']);
             $data['headers']['References'] = $references;
         }
         try {
             $messages[$user->ID] = $this->send_single($data);
         } catch (Exception $e) {
             $error = sprintf(__('Exception while sending: %s', 'falcon'), $e->getMessage());
             trigger_error($error, E_USER_WARNING);
         }
     }
     return $messages;
 }
Example #2
0
 public function send_mail($users, Falcon_Message $message)
 {
     $options = $message->get_options();
     $from = Falcon::get_from_address();
     if ($author = $message->get_author()) {
         $from = sprintf('%s <%s>', $author, $from);
     }
     $messages = array();
     foreach ($users as $user) {
         $data = array('From' => $from, 'ReplyTo' => $message->get_reply_address($user), 'To' => $user->user_email, 'Subject' => $message->get_subject(), 'Headers' => array());
         if ($text = $message->get_text()) {
             $data['TextBody'] = $text;
         }
         if ($html = $message->get_html()) {
             $data['HtmlBody'] = $html;
         }
         // Set the message ID if we've got one
         if (!empty($options['message-id'])) {
             $data['Headers'][] = array('Name' => 'Message-ID', 'Value' => $options['message-id']);
         }
         // If this is a reply, set the headers as needed
         if (!empty($options['in-reply-to'])) {
             $original = $options['in-reply-to'];
             if (is_array($original)) {
                 $original = isset($options['in-reply-to'][$user->ID]) ? $options['in-reply-to'][$user->ID] : null;
             }
             if (!empty($original)) {
                 $data['Headers'][] = array('Name' => 'In-Reply-To', 'Value' => $original);
             }
         }
         if (!empty($options['references'])) {
             $references = implode(' ', $options['references']);
             $data['Headers'][] = array('Name' => 'References', 'Value' => $references);
         }
         $messages[$user->ID] = $this->send_single($data);
     }
     return $messages;
 }