Blog Detail

12

Aug
Check if you can Send Email via Given Mail Server in Laravel cover image

arrow_back Check if you can Send Email via Given Mail Server in Laravel

Mail SPF Checker is a Laravel package to check if your application can send an e-mail in name of a given address.

Most web applications are sending emails. Mostly through a local mail server or an external mailing service.
When sending in name of a domain without using the legitimate mail server 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 address using the mail server specified in your mail config or a given mail server. It also gives the possibility to retrieve a DNS txt record to configure your DNS.

Compatibility

This package can be installed in Laravel 6,7,8 and 9.

Installation

You can install this package via composer by running this command.

composer require dietercoopman/mailspfchecker

Usage Examples

Using the mailserver used by your application

    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
    }

Using a given mailserver

    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
    }

For more details, Visit Github.

Closing Notes

The team of Codebrisk Laravel developers is always ready to execute even your boldest ideas. Our expert team can design and develop any type of custom CRM solution, SAAS app, or e-commerce app to meet our customer’s needs and transform our customer’s experiences. Get in touch with our team to discuss your bespoke ideas and learn more about the next steps to launching cooperation.

Published at : 12-08-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project