Skip to content

Commit

Permalink
Added Example
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jul 16, 2022
1 parent 23028e4 commit b4e5c13
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Binary file added example/AttachmentImg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions example/sendMail.php
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';

0 comments on commit b4e5c13

Please sign in to comment.