Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2018
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. require __DIR__ . '/vendor/autoload.php';
  4.  
  5. $smtpHost = 'ssl://smtp.yandex.com';
  6. $smtpPort = 465;
  7. $security = null;
  8. $smtpUsername = 'mob-pro-test@yandex.ru';
  9. $smtpPassword = 'mob-pro1234';
  10.  
  11. /*
  12.  * Create the Transport
  13.  */
  14. $transport = (new Swift_SmtpTransport($smtpHost, $smtpPort, $security))
  15.     ->setUsername($smtpUsername)
  16.     ->setPassword($smtpPassword)
  17. ;
  18. //$transport = Swift_SmtpTransport::newInstance('smtp.yandex.ru', 465, 'ssl')/
  19. //     ->setUsername('email@yandex.ru')
  20. //->setPassword('password');
  21. /*
  22.  * Create the Mailer using your created Transport
  23.  */
  24. $mailer = new Swift_Mailer($transport);
  25.  
  26. /*
  27.  * Create a message
  28.  */
  29. $from = ['john@doe.com' => 'John Doe'];
  30. $to = 'yury_borisov@rambler.ru';
  31. $subject = 'Wonderful Subject';
  32. $body = 'Test';
  33. $message = (new Swift_Message($subject))
  34.     ->setFrom($from)
  35.     ->setTo([$to])
  36.     ->setBody('Here is the message itself')
  37. ;
  38.  
  39. /*
  40.  * Send the message
  41.  */
  42. $result = $mailer->send($message);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement