New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

actweb/mail-auth

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

actweb/mail-auth

Mail server authentication class, allows authenticating users against POP/IMAP/SMTP with or without SSL

Source
Packagist
Version
0.5
Version published
Total downloads
23
Maintainers
1
Created
Source

mailAuth

Overview

PHP Class to authenticate a user against a mail server.

Specification

Allow setting of auth type : POP3, POP3S, IMAP, IMAPS, SMTP, SMTPS.

Take a username and a password and then attempt a login to the specified mail server.

If login is successful, then return true, else return false.

SMTP authentication function adapted from : http://support.webecs.com/kb/a390/php-mail-script-with-smtp-authentication.aspx

Usage

Configurable settingsDefault ValueDescription
mailServerUrlNONEMailserver URL
serverPortNONEMailserver Port number, normally automatically set after by setting the serverType, but can be overridden if required
serverTypeNONEService to use for authentication POP3/POP3S/IMAP/IMAPS/SMTP/SMTPS
serverTypesArray of TypesBuilt in list of valid services for authentication
errorsArray of ErrorsList of all error codes, there description and some help text on what the issue may be
usernameNONESet to the username to be used for authentication
passwordNONESet to the password to be used for authentication
passwordTypeplainCurrently on 'plain' is used, possible future enhancement to allow form based password encryption
passwordTypesList of supported passwordTypes, currently only 'plain' is supported
loggerNull Logger\Monolog\Logger if passed to constructor, this is used for all logging
sslChecktrueIf true, then perform SSL verification on the connection. NOTE If using POP or IMAP, this should be set to 'false' as some bug causes PHP imap_open to still check SSL when using non-ssl connection
authenticatedEMPTYStatus of the authentication, set to True after user sucsesfully authenticates or False otherwise
timeOut30Time out for SMTP connections, best to set this to a low value, as the authentication script will wait till this timeout if there is an issue connecting to the server
newLine\r\nEnd Of Line terminator to use in SMTP comunications
smtpLocalHostNONELocal hostname for SMTP authentication, not currently used, will most likely be removed in a future revision.
Setup Logging, not required but good for debug
$logger=new Logger('auth');
$logger->pushHandler(new StreamHandler(__DIR__.'/auth.log', LOGGER::DEBUG));
$logger->info('Auth Script Starting');

After authenticate() has been called, you can check the result of the authentication with :

$result=$auth->authenticated;

SMTP Authentication

$auth=new MailAuth($logger);
$auth->setMailServerUrl('MySMTPServerHostName');
$auth->setServerType('SMTP');
$auth->setSmtpLocalHost('MyLocalHostName');
$auth->setTimeOut(10);
$auth->setSslCheck(false);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();

SMTPS Authentication

$auth=new MailAuth($logger);
$auth->setMailServerUrl('MySMTPServerHostName');
$auth->setServerType('SMTPS');
$auth->setSmtpLocalHost('MyLocalHostName');
$auth->setTimeOut(10);
$auth->setSslCheck(true);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();

POP3 Authentication

$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyPOPServerHostName');
$auth->setServerType('POP3');
$auth->setSslCheck(false);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();

POP3S Authentication

$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyPOPServerHostName');
$auth->setServerType('POP3S');
$auth->setSslCheck(true);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();

IMAP Authentication

$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyIMAPServerHostName');
$auth->setServerType('IMAP');
$auth->setSslCheck(false);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();

IMAPS Authentication

$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyIMAPServerHostName');
$auth->setServerType('IMAPS');
$auth->setSslCheck(true);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();

Keywords

auth

FAQs

Package last updated on 13 Sep 2018

Related posts