Ad

Laravel - Connection Could Not Be Established With Host Smtp.gmail.com

- 1 answer

I've tried all the possible solutions available here in stackoverflow, however nothing... I think the problem is related to the firewall, I can send mail using SMTP gmail on my local machine, but not in my server, I get the following message:

Connection could not be established with host smtp.gmail.com [Connection timed out #110]

I've tried the following commands:

ufw allow 587/tcp

iptables -I OUTPUT -p tcp --dport 587 -j DROP

iptables -I OUTPUT -d smtp.gmail.com -p tcp -m tcp --dport 587 -j ACCEPT

iptables -L OUTPUT -n

However not worked...

This is my .env email settings:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*****@gmail.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=tls

My controller for sending emails:

public function postEmail(PostEmailRequest $request)
{
    if ($request){
        Mail::send('app.pages.contato.email', $request->all(), function($message) use ($request)
        {
            $message->from($request->email , config('settings.website_title'));
            $message->to(config('settings.admin_email'))->subject($request->assunto);
        });

        return redirect('contato');
    }else{
        return redirect('contato')->withErrors($request);
    }
}
Ad

Answer

I sent a ticket to Digital ocean and that is the obtained answer:

Hello!

To curb a recent increase in abuse and SPAM, we have an initial SMTP block on new accounts created in certain contexts.

To remove that block we'd like to do some manual account verification.

Please let us know the following:

  • Your Name
  • Location
  • Phone Number
  • The reason you are requesting the removal of the SMTP block

Also, please provide as many of the following as you can to help us verify your identity:

  • Your public Twitter handle
  • Your blog
  • Your company or personal website
  • Your public Facebook profile

We take SPAM very seriously as we comply fully with the CAN-SPAM Act. If you're not familiar, this says that you may not send bulk email unless you maintain a double-authorized list of subscribed members including IP addresses and relevant contact information. Also, you must follow guidelines for including removal links with all sent emails according to the CAN-SPAM Act.

If you have any questions we're happy to help answer them for you.

Regards, DigitalOcean Support

Edit


I replied with the information that was requested and now everything works perfectly =)

Ad
source: stackoverflow.com
Ad