Last active
September 1, 2022 06:09
-
-
Save LeoOnTheEarth/e07d2764458d2486ab00e43f085edb1e to your computer and use it in GitHub Desktop.
SwiftMailer 範例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 需要先安裝 swiftmailer | |
// composer require "swiftmailer/swiftmailer:^6.0" | |
require __DIR__ . '/vendor/autoload.php'; | |
// Create the Transport | |
$transport = (new Swift_SmtpTransport('email-smtp.us-east-1.amazonaws.com', 587, 'tls')) | |
->setUsername('username') | |
->setPassword('password') | |
; | |
// Create the Mailer using your created Transport | |
$mailer = new Swift_Mailer($transport); | |
// Create a message | |
$message = (new Swift_Message('Wonderful Subject')) | |
->setFrom(['gamehours@gamehours.com' => 'GameHours']) | |
->setTo(['leo.tsun@gamehours.com']) | |
->setBody('Here is the message itself') | |
; | |
// Send the message | |
$result = $mailer->send($message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment