183 | | |
184 | | // If it's actually got contents |
185 | | if ( !empty( $tempheaders ) ) { |
186 | | // Iterate through the raw headers |
187 | | foreach ( $tempheaders as $header ) { |
188 | | // Explode them out |
189 | | list( $name, $content ) = explode( ':', trim( $header ), 2 ); |
190 | | |
191 | | // Cleanup crew |
192 | | $name = trim( $name ); |
193 | | $content = trim( $content ); |
194 | | |
195 | | // Mainly for legacy -- process a From: header if it's there |
196 | | if ( $name == 'From' ) { |
197 | | if ( strpos( '<', $content ) !== false ) { |
198 | | // So... making my life hard again? |
199 | | $from_name = substr( $content, 0, strpos( '<', $content ) - 1 ); |
200 | | $from_name = str_replace( '"', '', $from_name ); |
201 | | $from_name = trim( $from_name ); |
202 | | |
203 | | $from_email = substr( $content, strpos( '<', $content ) + 1 ); |
204 | | $from_email = str_replace( '>', '', $from_email ); |
205 | | $from_email = trim( $from_email ); |
206 | | } else { |
207 | | $from_name = trim( $content ); |
208 | | } |
209 | | } elseif ( $name == 'Content-Type' ) { |
210 | | if ( strpos( ';', $content ) !== false ) { |
211 | | list( $type, $charset ) = explode( ';', $content ); |
212 | | $content_type = trim( $content_type ); |
213 | | $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) ); |
214 | | } else { |
215 | | $content_type = trim( $content ); |
216 | | } |
| 183 | } else { |
| 184 | // We were passed an array of raw headers. |
| 185 | $tempheaders = $headers; |
| 186 | $headers = array(); |
| 187 | } |
| 188 | |
| 189 | // If it's actually got contents |
| 190 | if ( !empty( $tempheaders ) ) { |
| 191 | // Iterate through the raw headers |
| 192 | foreach ( $tempheaders as $header ) { |
| 193 | // Explode them out |
| 194 | list( $name, $content ) = explode( ':', $header, 2 ); |
| 195 | |
| 196 | // Cleanup crew |
| 197 | $name = trim( $name ); |
| 198 | $content = trim( $content ); |
| 199 | |
| 200 | // Mainly for legacy -- process a From: header if it's there |
| 201 | if ( $name == 'From' ) { |
| 202 | if ( strpos( $content, '<' ) !== false ) { |
| 203 | // So... making my life hard again? |
| 204 | $from_name = substr( $content, 0, strpos( $content, '<' ) - 1 ); |
| 205 | $from_name = str_replace( '"', '', $from_name ); |
| 206 | $from_name = trim( $from_name ); |
| 207 | |
| 208 | $from_email = substr( $content, strpos( $content, '<' ) + 1 ); |
| 209 | $from_email = str_replace( '>', '', $from_email ); |
| 210 | $from_email = trim( $from_email ); |
| 214 | } elseif ( $name == 'Content-Type' ) { |
| 215 | if ( strpos( ';', $content ) !== false ) { |
| 216 | list( $type, $charset ) = explode( ';', $content ); |
| 217 | $content_type = trim( $type ); |
| 218 | $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) ); |
| 219 | } else { |
| 220 | $content_type = trim( $content ); |
| 221 | } |
| 222 | } else { |
| 223 | // Add it to our grand headers array |
| 224 | $headers[$name] = $content; |