| 83 | * @ticket 15448 |
| 84 | */ |
| 85 | function test_wp_mail_plain_and_html() { |
| 86 | $to = 'user@example.com'; |
| 87 | $subject = 'Test email with plain text and html versions'; |
| 88 | $messages = array( 'text/plain' => 'Here is some plain text.', |
| 89 | 'text/html' =>'<html><head></head><body>Here is the HTML with UTF-8 γειά σου Κόσμε;-)<body></html>' ); |
| 90 | |
| 91 | wp_mail( $to, $subject, $messages ); |
| 92 | |
| 93 | preg_match( '/boundary="(.*)"/', $GLOBALS['phpmailer']->mock_sent[0]['header'], $matches); |
| 94 | $boundry = $matches[1]; |
| 95 | $body = 'This is a multi-part message in MIME format. |
| 96 | |
| 97 | --' . $boundry . ' |
| 98 | Content-Type: text/plain; charset=us-ascii |
| 99 | |
| 100 | Here is some plain text. |
| 101 | |
| 102 | |
| 103 | --' . $boundry . ' |
| 104 | Content-Type: text/html; charset=UTF-8 |
| 105 | Content-Transfer-Encoding: 8bit |
| 106 | |
| 107 | <html><head></head><body>Here is the HTML with UTF-8 γειά σου Κόσμε;-)<body></html> |
| 108 | |
| 109 | |
| 110 | |
| 111 | --' . $boundry . '-- |
| 112 | '; |
| 113 | // We need some better assertions here but these test the behaviour for now. |
| 114 | $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']); |
| 115 | } |
| 116 | |
| 117 | /** |