SendNormalMailTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * 普通发送接口
  4. * User: chocoboxxf
  5. * Date: 16/9/23
  6. */
  7. namespace chocoboxxf\SendCloud\Tests;
  8. class SendNormalMailTest extends BaseTest
  9. {
  10. public function testSendPlain()
  11. {
  12. $subject = '测试plain邮件';
  13. $content = 'this is a test plain text';
  14. $to = ['user_a@company.com', ];
  15. $from = 'admin@company.com';
  16. $fromName = 'Admin';
  17. $templateData = [
  18. ];
  19. $attachments = [
  20. __DIR__ . '/data/test.pdf',
  21. ];
  22. var_dump($this->client->sendNormalMail($subject, $content, $to, $from, $fromName, $templateData, $attachments));
  23. }
  24. public function testSendHtml()
  25. {
  26. $subject = '测试html邮件';
  27. $content = '<html><h1>this is a test html text</h1></html>';
  28. $to = ['user_a@company.com', ];
  29. $from = 'admin@company.com';
  30. $fromName = 'Admin';
  31. $templateData = [
  32. ];
  33. $attachments = [
  34. __DIR__ . '/data/test.txt',
  35. ];
  36. var_dump($this->client->sendNormalMail($subject, $content, $to, $from, $fromName, $templateData, $attachments));
  37. }
  38. public function testSendHtmlWithData()
  39. {
  40. $subject = '测试带变量的html邮件';
  41. $content = '<html><h1>this is a test %key% html text</h1></html>';
  42. $to = ['user_a@company.com', ];
  43. $from = 'admin@company.com';
  44. $fromName = 'Admin';
  45. $templateData = [
  46. 'key' => 'value',
  47. ];
  48. $attachments = [
  49. __DIR__ . '/data/test.pdf',
  50. ];
  51. var_dump($this->client->sendNormalMail($subject, $content, $to, $from, $fromName, $templateData, $attachments));
  52. }
  53. }