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

MrRobot21's avatar

Mailgun Mail Sending problem

Hi Awesome People

I have been trying to send mail on submitting a form with gmail which din't work so now i created a free mailgun account and tried implementing but i'm facing issues with this too, idk all mail services are angry at me or something

Now i'm Getting the bellow error

RequestException in CurlFactory.php line 187:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I did installed guzzle by adding "guzzlehttp/guzzle": "~5.3|~6.0" and updated the composer

My Configration in ".env" is

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster@sandbox############.mailgun.org
MAIL_PASSWORD=Mygunpass
MAIL_ENCRYPTION=tls

MAILGUN_DOMAIN=sandbox#############.mailgun.org
MAILGUN_SECRET=key-#####224##########

And In "Service.php"

    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
    ],

And My Form is contact.blade.php

  <form method="POST" action="contact" id="contact_form" class="contact-form custm-form" role="form" 
enctype="multipart/form-data">
                    {!! csrf_field() !!}
                    <div class="row">
                      <div class="col-md-6">
                        <ul class="row">
                          <li class="col-sm-12">
                            <label>
                              <input type="text" class="form-control" name="name" id="name" placeholder="Your Name" required>
                            </label>
                          </li>
                          <li class="col-sm-12">
                            <label>
                              <input type="email" class="form-control" name="email" id="email" placeholder="E-Mail" required>
                            </label>
                          </li>
                          <li class="col-sm-12">
                            <label>
                              <input type="number" class="form-control" name="phone" id="phone" placeholder="Phone" required>
                            </label>
                          </li>
                          <li class="col-sm-12">
                            <label>
                              <input type="text" class="form-control" name="subject" id="subject" placeholder="Subject" required>
                            </label>
                          </li>
                        </ul>
                      </div>
                      <div class="col-md-6">
                        <ul class="row">
                          <li class="col-sm-12">
                            <label>
                              <textarea class="form-control" name="message" id="message" rows="5" placeholder="Your Message"></textarea>
                            </label>
                          </li>
                          <li class="col-sm-12">
                            <button type="submit" value="submit" class="btn" id="btn_submit">Send Message</button>
                          </li>
                        </ul>
                      </div>
                    </div>
      </form>

And My Controller is AcoContactController.php

<?php

namespace App\Http\Controllers;

use View;
Use Mail;
use App\AvoContact;
use App\Http\Requests;
use App\Http\Requests\ContactFormRequest;
use Illuminate\Routing\Controller as BaseController;


class AvoContactController extends BaseController {

    public function contactpage()
    {
        $contact = AvoContact::all();

        return view('pages.contact')->with(['contact' => $contact]);
    }

    public function store(ContactFormRequest $request)
    {
        Mail::send('emails.contact', [], function ($m) use($request){
            $m
              ->from(env('MAIL_USERNAME')) // also tried postmaster@sandbox############.mailgun.org
              ->to('sanjiarya2112@gmail.com')
              ->subject('Your Reminder!');
        });

        return 'Email Sent';

    }  

}

And The Route is

Route::get('contact', 'AvoContactController@contactpage');
Route::post('contact', 'AvoContactController@store');

I have Posted all my code, i really can't seem finding what is the issue with sending mail

Looking forward for much needed help

Thank You

0 likes
12 replies
bashy's avatar

Make sure you set your DNS up correctly on your machine. Using Google's works fine for grabbing the remote cert required for cURL.

MrRobot21's avatar

@bashy Thanks for your time and help

I got that fixed by adding http://curl.haxx.se/ca/cacert.pem this file link to php.ini

Now i'm getting a different error

Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/answer/14257 fn3sm68484046pab.20 - gsmtp
"

My .env

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster@sandbox############.mailgun.org
MAIL_PASSWORD=Mygunpass
MAIL_ENCRYPTION=tls

MAILGUN_DOMAIN=sandbox#############.mailgun.org
MAILGUN_SECRET=key-#####224##########

My service.php

    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
    ],

I don't know what i have missed

Thank You

bashy's avatar

That's related to Gmail not accepting your credentials. Looks like you're looking at the wrong error line or you're using Google.

1 like
MrRobot21's avatar

@bashy My Bad, i'm sorry, now i re-run the php artisan serve and tried sending mail but got the previous error i sorry i got why that was happening

Now i'm getting the same old error

RequestException in CurlFactory.php line 187:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

And about that, am i suppose to change the IPv4 configration in my settings

Thank You

bashy's avatar

What is your current DNS on your server?

cat /etc/resolv.conf
MrRobot21's avatar

@bashy Thanks a lot for your time i really appreciate it

I'm using windows i think there is no resolv.conf windows equivalent so you know

I'm using google mail again now it is working fine, and i'm gona stick with gmail for now

Thank a lot for your time

bashy's avatar

Just look in networks and then the adapter, check in the IPv4 DNS section.

tjm's avatar

I looked into the errors on Mailgun's side -- turns out, it was because I was still attempting to send from the sandbox account:

[email protected] # replace sandbox1239177 one with your domain
MAIL_PASSWORD=SOMETHING             # password for your SMTP account
MAILGUN_DOMAIN=domain.com
MAILGUN_SECRET=key-secret9182381279

Please or to participate in this conversation.