Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@

# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,phpstorm,netbeans,composer
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,phpstorm,netbeans,composer

### Composer ###
composer.phar
/lib_ext/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### NetBeans ###
**/nbproject/private/
**/nbproject/Makefile-*.mk
**/nbproject/Package-*.bash
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

### PhpStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/
.idea
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### PhpStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos,phpstorm,netbeans,composer
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
# notification
This is a library that uses composer as the basis for generating email notifications
# Notification library via email using phpMailer

This library has the function of sending e-mail using the phpmailer library. Doing this in an uncomplicated way is essential for any system.

To install the library, run the following command:

``` sh
composer require gustavoweb/composer_teste
```

To use the library, simply require the composer to autoload, invoke the class and call the method:

``` sh
<? php

require __DIR__. '/vendor/autoload.php';

USE Notification \ Email;

$ email = new Email (2, "mail.host.com", "your@email.com", "your-pass", "smtp secure (tls/ssl)", "port (587)", "from@email.com", "From Name");

$ email-> sendEmail ("Subject", "Content", "reply@email.com", "Replay Name", "address@email.com", "Address Name");
```

Note that the entire configuration of sending the email is using the magic method builder! Once the builder method has been invoked within your application, your system will be able to take the shots.

### Developers
* [Gustavo Web] - Developer of this library and tutor of the Composer na Prática course!
* [Robson V. Leite] - CEO and Founder UpInside Trainamentos
* [UpInside Treinamentos] - Official website of your digital marketing and programming school
* [phpMailer] - Lib to send E-mail

License
----

MIT

** Another UpInside Training course, make good use of it! **

[//]: #
[Gustavo Web]: <mailto: gustavo@upinside.com.br>
[Robson V. Leite]: <mailto: robson@upinside.com.br>
[UpInside Treinamentos]: <https://www.upinside.com.br>
[phpMailer]: <https://github.com/PHPMailer/PHPMailer>
43 changes: 43 additions & 0 deletions _app/Email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Notification;

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

class Email
{
private $mail = \stdClass::class;

public function __construct($smtpDebug, $host, $user, $pass, $smtpSecure, $port, $setFromEmail, $setFromName)
{
$this->mail = new PHPMailer(true);
$this->mail->SMTPDebug = $smtpDebug; // Enable verbose debug output
$this->mail->isSMTP(); // Send using SMTP
$this->mail->Host = $host; // Set the SMTP server to send through
$this->mail->SMTPAuth = true; // Enable SMTP authentication
$this->mail->Username = $user; // SMTP username
$this->mail->Password = $pass; // SMTP password
$this->mail->SMTPSecure = $smtpSecure; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$this->mail->Port = $port; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
$this->mail->CharSet = 'utf-8';
$this->mail->setLanguage('br');
$this->mail->isHTML(true);
$this->mail->setFrom($setFromEmail, $setFromName);
}

public function sendMail($subject, $body, $replyEmail, $replyName, $addressEmail, $addressName)
{
$this->mail->Subject = (string)$subject;
$this->mail->Body = $body;

$this->mail->addReplyTo($replyEmail, $replyName);
$this->mail->addAddress($addressEmail, $addressName);

try {
$this->mail->send();
} catch (Exception $e) {
echo "Erro ao enviar o e-mail: {$this->mail->ErrorInfo} {$e->getMessage()}";
}
}
}
26 changes: 26 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "rogarfil/notification",
"description": "This is a library that uses composer as the basis for generating email notifications",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "rogarfil",
"email": "rogarfil@yahoo.com.br",
"homepage": "http://www.rogarfil.com.br",
"role": "Developer"
}
],
"minimum-stability": "dev",
"require": {
"phpmailer/phpmailer": "6.1.4"
},
"config": {
"vendor-dir": "lib_ext"
},
"autoload": {
"psr-4": {
"Notification\\": "_app"
}
}
}
Loading