quick-phpmailer-wrapper/index.php

41 lines
917 B
PHP
Raw Normal View History

2019-09-15 17:08:44 +00:00
<?php
require 'vendor/autoload.php';
// for testing use only. Please define user, password and host in a config file of your own
$mail = new MailWrapper();
$mail
->setHost("smtp.spacejewel-hosting.com") // can be anything that has a mail server
->setProtocol("tls") // auto sets the port
->setAuthPassword("examplepassword")
->setFullyQualifiedAddress("exampleuser")
->setRecipient("johndoe@example.com")
->setReplyto("someone@example.com")
2019-09-15 18:27:55 +00:00
->setFrom("someone@example.com", "From Name Here")
2019-09-15 17:08:44 +00:00
->prepare();
$content = <<<EOL
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>Hello,</p>
<p>This is a sample test message</p>
</body>
</html>
EOL;
try
{
$mail->send("Test message", $content);
}
catch (Exception $ex)
{
echo "Problem while sending mail! " . $ex->getMessage();
}