Mailgun: How can send email from my local machine (Laravel) - laravel

I have setup Mailgun on my Laravel project, the project will be deployed on a (Lan based) local server which hopefully connected to internet, email should be sent from the local machine where the project is being hosted, it works great on my dev server but when I try to send email from my local machine it returns below error.

cURL error 60: SSL cert issue when sending email with artisan command
You can either modify the vendor folder GuzzleHttp\Client change verify key to false from configureDefaults method as I did in my local machine
or
You can read this conversation in Laracasts and try downloading the .pem files in some of the comments.
Here are some links:
.pem File Download
After that you should edit your php.ini file accordingly:
curl.cainfo = "[pathtothisfile]\cacert.pem"
PS: I would just edit the vendor file, because it's much faster and not hard to realize.

The reason is because the mailgun/guzzleHttp looking for valid certificate (SSL issue) for security reasons.
You can solve it like below (Wamp server):
1- Download this file from http://curl.haxx.se/ca/cacert.pem and put this in "C:/wamp64/bin/php/(your php version)/extras/ssl/" directory
2- find all php.ini files (even php.ini-production and php.ini-development) under this directory "C:/wamp64/bin/php/php (your php version)"
3- find these following parts in above .ini files and edit it as shown:
curl.cainfo = "C:/wamp64/bin/php/(your php version)/extras/ssl/cacert.pem"
openssl.cafile= "C:/wamp64/bin/php/(your php version)/extras/ssl/cacert.pem"
4- clear cache laravel and restart your laravel server
5- restart wamp server

Related

How to run laravel websockets in laragon?

How to run laravel websockets in laragon?
when run command to start websockets
php artisan websockets:serve
it's not working because
https://imgur.com/ODkZC8d
and its still suck there
https://imgur.com/6lzEOGX
this is error on browser
WebSocket connection to 'wss://nextlevelbot.test:6001/app/mykey?protocol=7&client=js&version=6.0.2&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
It was my problem in SSL certifacates
I solve this problem by create SSL certificates for nextlevelbot.test and add them in folder in this path
C:\laragon\etc\ssl\nextlevelbot.test
and add path SSL certificates in .env file
LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT =C:\laragon\etc\ssl\nextlevelbot.test\server.crt
LARAVEL_WEBSOCKETS_SSL_LOCAL_PK =C:\laragon\etc\ssl\nextlevelbot.test\server.key
and edit path SSL certificates in config file for my project in this path
C:\laragon\etc\nginx\sites-enabled\auto.nextlevelbot.test.conf
ssl_certificate "C:/laragon/etc/ssl/nextlevelbot.test/server.crt";
ssl_certificate_key "C:/laragon/etc/ssl/nextlevelbot.test/server.key";
and restart nginx server in laragon
and run command composer dumpautoload
after that run command php artisan websockets:serve
after that work good :)
Generate certificates for domain
I generate certificates by this scripts
https://gist.github.com/mindscms/721cf0968ddbbff5bad0c0b359d918e6
https://gist.github.com/mindscms/a7f3e7db0b6c7bfaaab56522ebed9042
1 - Download two files make-cert.bat and cert-template.conf from link above
2 - Create folder cert in C:\laragon\bin\apache\YOUR_VIRSION_APACHE
in my case C:\laragon\bin\apache\httpd-2.4.35-win64-VC15\cert
3 - Put two file make-cert.bat and cert-template.conf in folder cert
4 - Run file make-cert.bat and answer the questions to generate certificates
5 - After finished script creates a folder with the name domain likenextlevelbot.test
C:\laragon\bin\apache\httpd-2.4.35-win64-VC15\cert\nextlevelbot.test
6 - Inside this folder two files server.crt and server.key
That was helpful but not the exact reason
as this is a local cert, it needs permission
The easiest way ( oh its quirky )
Copy the failing wss link
i.e. wss://example.test:3031/app/?protocol=7&client=js&version=4.3.1&flash=false
and replace the wss:// with https://
i.e.
https://example.test:3031/app/?protocol=7&client=js&version=4.3.1&flash=false
Open the link on another tab of same browser and accept the certification on ssl prompt
try the websockets dashboard now, refresh and voila!
By the way, if you make any change to your nginx config for domain in laragon, you should remove the auto. prefix to avoid future auto overwrite by laragon

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

GuzzleHttp\Exception\RequestException
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
how to solve this error i am trying everything available on the google including
the below description several times
Download this file: http://curl.haxx.se/ca/cacert.pem
Place this file in the C:\wamp64\bin\php\php7.1.9 folder
Open php.iniand find this line:
;curl.cainfo
Change it to:
curl.cainfo = "C:\wamp64\bin\php\php7.1.9\cacert.pem"
But still it didn't work for me
please help me i am so frustrated right now...
You need to put .pem file inside of C:\wamp64\bin\php\php7.1.9\extras\ssl instead of C:\wamp64\bin\php\php7.1.9
Make sure the file mod_ssl.so is inside of C:\wamp64\bin\apache\apache(version)\modules
Enable mod_ssl in httpd.conf inside of Apache directory C:\wamp64\bin\apache\apache2.4.27\conf
Enable php_openssl.dll in php.ini.
In wamp there are two php.ini files and You need to do this in both of them.
First one can be located inside of your WAMP taskbar icon
and the other one is located in C:\wamp64\bin\php\php(Version)
find the location for both of the php.ini files and find the line curl.cainfo = and give it a path like this
curl.cainfo = "C:\wamp64\bin\php\php7.1.9\extras\ssl\cacert.pem"
Now save the files and restart your server
In my case this error also happened when using Laravel's development server.
In order to fix it, just shifted stopped that server and ran Apache through XAMPP and that was enough to solve the problem.
If you're having troubles with this approach, please read the answers to this question for more details.

Laravel Local Routes on server after deployment

My problem is that i tried to upload my project to the server (using filezilla uploaded the whole thing) and encountered this error:
"The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."
Searching on google, people says its a key problem on .env file. But that wasn't my case. the Key is there, I even use php artisan key:generate. it's like the server isn't reading the .env file
I tried config:cache and uploaded the "config.php" that was generated inside the cache folder and now the app cant finds the "views" because the paths are not the server paths but the local ones.
I tried everything, even uploading a fresh laravel installation and again: "The only supported ciphers are AES-128-CBC.."
Also tried config:cache on the server using the routes:
Route::get('/config-cache', function() { $exitCode = Artisan::call('config:cache'); return 'done.'; });
But i get this error: "putenv() has been disabled for security reasons"
I don't really know how to proceed..
You are getting this error because you have to generate key
try
php artisan key:generate
Or generate locally then replace it with .env
APP_KEY=YourGeneratedKey

DigitalOcean: I want to download the .env file from server where laravel application installed

I am working on Laravel application on a DigitalOcean server. To speedup my programming I am going to clone my project to my local machine. But I did not find the .env file on the server.
Anyone, please help me getting the .env file from the DigitalOcean server.
The .env file is not tracked by git on the server, so when you git clone the repository from the server, it will not be included. Depending on the complexity of your project on the server, the .env file might include custom variables that are required for the project to function properly. So your best bet is to get a copy of the .env file from the server.
To manually copy the .env file from the server to your local machine using scp or similar tool:
$ scp username#server:/repo/.env /some/local/directory
Or, if you are using Laravel Forge to deploy to the DigiitalOcean server, you could log in to Forge and copy the contents of the .env from the interface.
But don't forget to customize the .env afterwards for your local environment (database credentials, etc).
In laravel project , .env file exit in the project root file, that does not matter if it is local or live.
So if you can not find the .evn file in your digital ocean server it is likely that you dont have it in your application .
What you can do is make a copy of .env.example and rename it to .env file.

Laravel 4.2 in FTP server throwing Error 500

I've searched everywhere for a solution. Plus, I tried tracking the error using echo("teste");, but can't find exactly what is wrong, since it works on my local host.
From index.php -> bootstrap/autoload.php -> vender/autoload.php:
I could print a msg until before the foreach in getLoader method of ComposerAutoloaderInitxxxxxx class.
I see it can't complete the require in both bootstrap/autoload.php or bootstrap/start.php
my directories levels are:
public_html/
|__laravel/
|__app/
|__bootstrap/
|__vender/
|__index.php
|__artisan
|__robots.txt
I've changed the paths correctly when moved the files from public/ to laravel root, since I can get into the files required (it just can't finish loading).
I get
500 (Internal Server Error)
Ps.: I uploaded the project through Filezilla, and I only have the FTP access.
Please, could someone help me with this?
Ok first you should not upload a Laravel project via FTP, if you only have an FTP access then you need a real hosting provider that has SSH. You should be able to use the composer command on your production server or you will be in big trouble later :)
Also, assuming this is a cPanel host (based on the public_html folder) the proper way would be to git clone the Laravel project under a folder, remove the public_html folder and create a symbolic link like this.
ln -s ~/laravel/public ~/public_html
This way your document root will point to Laravel's public folder.
Here is more information:
https://laracasts.com/discuss/channels/general-discussion/how-to-install-laravel-in-the-root-directory

Categories

Resources