-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
require '../vendor/autoload.php'; | ||
|
||
use webfiori\email\SMTPAccount; | ||
use webfiori\email\EmailMessage; | ||
|
||
//First, create new SMTP account that holds SMTP connection information. | ||
$smtp = new SMTPAccount([ | ||
'port' => 465, | ||
//Replace server address with your mail server address | ||
'server-address' => 'mail.example.com', | ||
//Replace server username with your mail server username | ||
'user' => '[email protected]', | ||
'pass' => 'KnvcbxFYCz77', | ||
'sender-name' => 'Ibrahim', | ||
//Replace sender address with your mail server sender address | ||
'sender-address' => '[email protected]', | ||
'account-name' => 'no-reply' | ||
]); | ||
|
||
//Second, create your actual email. using the account that was just created to | ||
//send messages. | ||
$email = new EmailMessage($smtp); | ||
|
||
//Set subject | ||
$email->setSubject('Hello World From PHP 😀'); | ||
|
||
//Optionally, set priority | ||
$email->setPriority(1); | ||
|
||
//Specify who will receive the message | ||
$email->addTo('[email protected]'); | ||
|
||
//Add optional attachments | ||
$email->addAttachment(__DIR__.DIRECTORY_SEPARATOR.'AttachmentImg.png'); | ||
|
||
//Build your HTML Message | ||
$div = $email->insert('div'); | ||
$div->addChild('p')->text('Hello World Message'); | ||
$div->addChild('p', [ | ||
'style' => [ | ||
'font-weight' => 'bold', | ||
'color' => 'red' | ||
] | ||
])->text('This is just a test message.'); | ||
|
||
//Finally, send. | ||
$email->send(); | ||
|
||
echo 'sent'; |