Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP support #50

Open
smpcasgit opened this issue Aug 7, 2019 · 1 comment
Open

SMTP support #50

smpcasgit opened this issue Aug 7, 2019 · 1 comment

Comments

@smpcasgit
Copy link

possible to send smtp email?

@nliautaud
Copy link
Owner

Issues with mail() :

  • uses local mail server configuration and may face host limitations
  • emails may being flagged as spam or rejected by some email providers
  • emails not delivered are lost in space
  • vulnerable to email injection attacks

Core advantages of mail libraries :

  • SMTP authentification for improved deliverability
  • email tracking, bounce handling, and automatic retries for failed deliveries
  • protection against header injection attacks

Disadvantages :

  • Requires installation
  • Requires an SMTP server
  • Requires configuration

See https://github.com/PHPMailer/PHPMailer

Requirements
The provided solution need to mitigate the complexity added by the usage of an SMTP setup, support a wide range of users and still work out of the box.

  • Support users that have PHPMailer installed
  • Support users that can use Composer
  • Support users that cannot use Composer (ex. shared hosting)
  • Support users that aren't tech savy enough to install or setup PHPMailer

Solution :

  • add dependency to PHPMailer when the repo is installed trough Composer.
  • use PHPMailer if installed and ready (server configured & connected)
  • fallback to mail() by default.
  • in the settings, add a section for SMTP :
    • some explanations
    • SMTP status : enabled, not connected or not installed (with a link to a documentation).
    • If the lib is not detected, a field for manually setting its relative path is provided. This feature would target the users that don't have the lib and can't use command line to install it, and would need to copy the PHPMailer files manually.
    • PHPMailer settings (SMTP server etc)
  • add errors handling and reporting for the whole flow
  • set PHPMailer language and extend the built-in translations as needed

Note that the implementation should loads PHPMailer whether installed trough composer or with a provided path to manually copied files.
For example switch between

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';

and

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'path/to/PHPMailer/src/Exception.php';
require 'path/to/PHPMailer/src/PHPMailer.php';
require 'path/to/PHPMailer/src/SMTP.php';

or bypassing autoload entirely ?

@nliautaud nliautaud changed the title how to send smtp email SMTP support Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants