A Laravel package to check if you can send e-mail through a given mailserver in name of a given e-mail address
A Laravel package to check if your application can send e-mail in name of a given address.
Most of the web applications are sending mails. Mostly through a local mail server or an external mailing service.
When sending in name of a domain without using the legitimate mailserver of the domain it can get tricky.
Most of the time your mail ends up in a spam folder. This can be solved by configuring a correct SPF record for the domain you are sending with. This package
gives you the possibility to check if you can send with a given from address using the mailserver specified in your mail config
or a given mailserver. It also gives the possibility to retrieve a dns txt record to configure your dns.
This package can be installed in Laravel 6,7,8,9 and 10
composer require dietercoopman/mailspfchecker
if ($mailSpfChecker->canISendAs("hello@dietse.dev")) {
// the happy path
} else {
// you can not send e-mail in name of hello@dietse.dev, but I can tell you what to do
echo $mailSpfChecker->howCanISendAs("hello@dietse.be");
// Generate a txt-record with a name of dietse.dev and the value v=spf1 ip4:#.#.#.# -all
}
if ($mailSpfChecker->using('smtp.mandrill.com')->canISendAs("hello@dietse.dev")) {
// the happy path
} else {
// you can not send e-mail in name of hello@dietse.dev, but I can tell you what to do
echo $mailSpfChecker->using('smtp.mandrill.com')->howCanISendAs("hello@dietse.be");
// Generate a txt-record with a name of dietse.dev and the value v=spf1 ip4:spf.mandrill.com -all
}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.