Download the PHP package shieldon/messenger without Composer
On this page you can find all versions of the php package shieldon/messenger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package messenger
Messenger
Sending messages to the third-party services made easy for PHP.
Supported modules:
- Telegram
- Line Notify
- Rocket Chat
- Slack
- Slack Webhook
- SMTP
- SendGrid
- MailGun
- MailGun (SMTP)
- Gmail (SMTP)
- Yahoo (SMTP)
- Outlook (SMTP)
More modules will come in the future...
Installation
Use PHP Composer:
Or, download it and include the Messenger autoloader.
Basic Usage
Public API methods:
- send
- debugMode
- printResult
Other than the Mailer classes, the only one public API is send()
. The only thing you need to do is to assign the required data fields into constructor when initializing instance.
Telegram
Open your Telegram App, add BotFather
to start a new conversation. Type command /newbot
to obtain your API key.
Remember, make sure your channel type is public. If you want to send messages to your private channel, googling will find solutions.
Line Notify
The access token can be obtained by clicking Generate token
button at this signup page.
Once you have obtained your developer access token for the chat group you choose, invite Line Notify
bot join your Line group, then the following code will work as expected.
RocketChat
Slack
Please clearfully read Slack's official API docs to find out things you need.
Guide:
- Create a App
- Assign
channels:read
andchat:write:bot
permissions to your App. - Assign your APP to your workspace.
- Obtain bot's access token.
- Add your App to the channel you would like to send messages.
Slack Webhook
This would be the simplest way for messaging. Please clearfully read Slack's official API docs to find out things you need.
ok.
Mailer Usage
Public API methods:
- send
- addTo
- addCc
- addBcc
- addReplyTo
- addRecipient
- setRecipients
- setSubject
- setSender
- debugMode
- printResult
There is no need to metion content type when using Mailer, the content type is automatically detected.
Native PHP mail function. To use this class, be sure you have set the settings right in your php.ini
.
SMTP
A very simple SMTP client.
Note:
If you would like to use SMTPS or STARTTLS, the $host
should have a prefix.
For example:
SendGrid
If you have SendGrid API key, you can also send messages via SendGrid easily.
MailGun
MailGun SMTP
Extended from Smtp
, a ready-to-use MailGun SMTP client.
Gmail
Extended from Smtp
, a ready-to-use Gmail SMTP client.
Note:
Google doesn't like people use their SMTP server to sending email by scripts, to make sure it can work without problems, you have to set the settings right:
- Check your Google Accounts -> Access for less secure apps -> Turn on
- Use your host where you use to send email with your Google account and confirm that you have trusted the device on.
Yahoo Mail
Extended from Smtp
, a ready-to-use Yahoo SMTP client.
Note: You can use your account password but if you are facing the following error:
That is because that Yahoo might not allow 3rd-party products access the SMTP server by default. To resolve this problem:
- Go to Account Security,
- Under Manage App password section, create a password for that App.
- Use your App password instead of your account password.
Outlook Mail (Office365)
Extended from Smtp
, a ready-to-use Yahoo SMTP client.
Note:
When sending email via Office365 SMTP server at the first time, you will receive a notification email from Outlook.com Team to confirm your activity.
Once you have completed the validation, you will be able to send email via Office365 SMTP server.
Debug
debugMode()
If you would like to catch exceptions, you use turn debugMode
on. This option will throw exceptions when error occurred.
For example:
printResult()
If you would like to print the executed results, you can use printResult()
.
For example:
If the email is sent successfully, the result will look like the text below:
Author
Messenger library is brought to you by Terry L. from Taiwan.
Shieldon Messenger is initially designed for a part of the Shieldon Firewall, sending notifications to webmasters or developers when their web applications are possibly under attacks. If you are looking for a web security library to protect your website, Shieldon Firewall might be a good choice for you.
License
MIT