Skip to content

Instantly share code, notes, and snippets.

@mdminhazulhaque
Created October 30, 2021 21:07
Show Gist options
  • Save mdminhazulhaque/8deabaab068f5b10979839b6e96ac432 to your computer and use it in GitHub Desktop.
Save mdminhazulhaque/8deabaab068f5b10979839b6e96ac432 to your computer and use it in GitHub Desktop.
Mail using SwiftMailer
<?php
require __DIR__.'/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
$transport = (new Swift_SmtpTransport('mail.example.com', 25))
->setUsername('user')
->setPassword('qwer0987');
$mailer = new Swift_Mailer($transport);
$message = (new Swift_Message('Hello World'))
->setFrom(['demo@example.com' => 'Demo'])
->setTo(['minhazul.haque@example.com' => 'Md Minhazul Haque'])
->setBody('Email from Demo');
$result = $mailer->send($message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment