本文整理汇总了PHP中CRM_Utils_Mail::formatRFC822Email方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Mail::formatRFC822Email方法的具体用法?PHP CRM_Utils_Mail::formatRFC822Email怎么用?PHP CRM_Utils_Mail::formatRFC822Email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Mail
的用法示例。
在下文中一共展示了CRM_Utils_Mail::formatRFC822Email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFormatRFC822
/**
* test case for add( )
* test with empty params.
*/
function testFormatRFC822()
{
$values = array(array('name' => "Test User", 'email' => "foo@bar.com", 'result' => "Test User <foo@bar.com>"), array('name' => '"Test User"', 'email' => "foo@bar.com", 'result' => "Test User <foo@bar.com>"), array('name' => "User, Test", 'email' => "foo@bar.com", 'result' => '"User, Test" <foo@bar.com>'), array('name' => '"User, Test"', 'email' => "foo@bar.com", 'result' => '"User, Test" <foo@bar.com>'), array('name' => '"Test User"', 'email' => "foo@bar.com", 'result' => '"Test User" <foo@bar.com>', 'useQuote' => TRUE), array('name' => "User, Test", 'email' => "foo@bar.com", 'result' => '"User, Test" <foo@bar.com>', 'useQuote' => TRUE));
foreach ($values as $value) {
$result = CRM_Utils_Mail::formatRFC822Email($value['name'], $value['email'], CRM_Utils_Array::value('useQuote', $value, FALSE));
$this->assertEquals($result, $value['result'], 'Expected encoding does not match');
}
}
示例2: testSend
/**
* Basic send.
*/
public function testSend()
{
$contact_params_1 = array('first_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'contact_type' => 'Individual');
$contact_id_1 = $this->individualCreate($contact_params_1);
$contact_params_2 = array('first_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Xylophone', 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'contact_type' => 'Individual');
$contact_id_2 = $this->individualCreate($contact_params_2);
$subject = 'Test spool';
$params = array('from' => CRM_Utils_Mail::formatRFC822Email($contact_params_1['first_name'] . " " . $contact_params_1['last_name'], $contact_params_1['email']), 'toName' => $contact_params_2['first_name'] . " " . $contact_params_2['last_name'], 'toEmail' => $contact_params_2['email'], 'subject' => $subject, 'text' => self::$bodytext, 'html' => "<p>\n" . self::$bodytext . '</p>');
CRM_Utils_Mail::send($params);
$mail = $this->_mut->getMostRecentEmail('raw');
$this->assertContains("Subject: {$subject}", $mail);
$this->assertContains(self::$bodytext, $mail);
$mail = $this->_mut->getMostRecentEmail('ezc');
$this->assertEquals($subject, $mail->subject);
$this->assertContains($contact_params_1['email'], $mail->from->email, 'From address incorrect.');
$this->assertContains($contact_params_2['email'], $mail->to[0]->email, 'Recipient incorrect.');
$context = new ezcMailPartWalkContext(array(get_class($this), 'mailWalkCallback'));
$mail->walkParts($context, $mail);
}