Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hekmatyar's avatar

Sending mails without smtp - Laravel 7

Hi, im doing this for first time, can someone explaine to me how can i do it? for now mails are saving in database but i want to sendmails to email without settings smtp (user,password etc)

config/mail.php -> https://pastebin.com/eZtN0F0E controller -> https://pastebin.com/YMaVxbXb mail/contact -> https://pastebin.com/DavbhsdL mailblade -> https://pastebin.com/QuTXm1UP

env: MAIL_MAILER=sendmail MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null

0 likes
7 replies
Snapey's avatar

you need a mail server to forward your mails to. It will then send to recipient.

Hekmatyar's avatar

i don't want forward mails..with mail server. only send directly to recipient by xmailer/sendmailer without smtp,pop etc settings.

kingmaker_bgp's avatar

You want to send Email without using any external Mail Servers (SMTP, SendGrid) ? just like a plain old PHP mail ( string $to , string $subject , string $message)?

Please do read below...

Brief History of SMTP (E-Mail Protocol)

The Simple Mail Transfer Protocol (SMTP) was a very old Protocol for sending E-Mail over Internet, invented in 1982. The SMTP Protocol doesn't have any strict Standards.

That mean, I can send an SMTP packet over Internet with whatever I want like following cases:

You can clearly see the above cases are absolutely Horrible and the SMTP protocol permits this

Blocking Spam / Scam / False E-Mail

In order to avoid such E-Mail, The E-Mail Receiver Servers (also called as Mail eXchange (MX) Server) like Gmail, Outlook, Yahoo, etcs checks for the Credibility of the received E-Mails by checking the Sender's IP and Security mail headers.

These IP / Sender Verification is done by means of an SPF Record and DKIM Record in the DNS of the respective yourdomain.com. These Record will be pre-populated by every Hosting Provider to allow successful sending of the E-Mail from [email protected].

In case these Records doesn't match with the received E-Mail, the E-Mail providers (Gmail, Outlook) will simply reject the Mail and won't even appear on the Spam folder. This is what happens mostly when we use native php mail() function.

Need for an SMTP Relay for successful E-mails

To avoid, these complications we use SMTP, SendGrid & other services to send E-mail successfully from Laravel.

1 like
Hekmatyar's avatar

Yes. becouse if i use smtp with forward mail, gmail block it as a danger/ virus and send it to spam with danger nothification. why you comlain it.. i want send data from form directly to provider without login to mail server. in other wise i need a function who change smtp settings in voyager admin panel.

Snapey's avatar

use a mail server and ensure you send email FROM an address that is authorised sender for that domain.

You cannot just hack your way past this and expect your email to be delivered. Its just not going to happen.

Hekmatyar's avatar

Ok, then how can i override env settings(use other mail config) to take data from database?

Please or to participate in this conversation.