Created
December 6, 2017 15:54
-
-
Save bmcclure/19e0fe0243d21224590ee7b532585b97 to your computer and use it in GitHub Desktop.
Set up SMTP mail sending on a custom PHP site
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
{ | |
"name": "topfloor/project-domain", | |
"description": "", | |
"minimum-stability": "stable", | |
"license": "proprietary", | |
"authors": [ | |
{ | |
"name": "Developer Name", | |
"email": "developer@email.address" | |
} | |
], | |
"repositories": [ | |
{ | |
"type": "git", | |
"url": "https://github.com/TopFloorTech/utility" | |
} | |
], | |
"require": { | |
"topfloor/utility": "dev-master" | |
} | |
} |
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 | |
/** | |
* Replace an instance of mail() with code similar to this | |
*/ | |
require_once dirname(__FILE__) . '/vendor/autoload.php'; | |
TopFloor\Utility\Config::setConfigDir(dirname(__FILE__) . '/config/'); | |
$message = TopFloor\Utility\Mailer::newMessage($subject); | |
$message->addTo($to) | |
->setFrom($from_email, $from_name) | |
->setBody($body, 'text/html'); | |
TopFloor\Utility\Mailer::send($message); |
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 | |
/** | |
* Save this as config/mail.php | |
*/ | |
return ['mail' => [ | |
'protocol' => 'Smtp', | |
'host' => 'email-smtp.us-west-2.amazonaws.com', | |
'port' => '587', | |
'security' => 'tls', | |
'username' => 'username', | |
'password' => 'password', | |
]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment