I'm using Laravel 5.1 and want to send email but I'm getting this 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)
How could I solve this?
My .env file:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=oEontENjBIdIrzaXhk9v9Q
My function in controller:
public function mailContact(ContactRequest $request)
{
$name = $request->input('name');
$email = $request->input('email');
$body = $request->input('body');
$sent = Mail::send('emails.contact', compact('name', 'email', 'body'), function ($message) {
$message->to('khudadadrs#gmail.com', 'Admin')->subject('Message');
});
if ($sent) {
return Redirect::back()->withMessage('تشکر از اینکه تماس گرفتید.');
}
return Redirect::back()->withError('متاسفانه ایمیل ارسال نشد.دوباره تلاش کنید');
}
Download the https://gist.github.com/VersatilityWerks/5719158/download
Extract it an place it in ..\php\ext (curl.cainfo="E:\xampp\php\ext)"
Open the php.ini and write after the php_curl.dll: curl.cainfo="..\php\ext\cacert.pem"(curl.cainfo="E:\xampp\php\ext\cacert.pem")
Restart the web server.
I added the cacert.pem file as described in http://codeontrack.com/solve-laravelxamppguzzlehttp-curl-error-60-no-sll-certificate/
but now I'm getting this error:
RequestException in CurlFactory.php line 187:
cURL error 77: error setting certificate verify locations:
CAfile: [pathtothisfile]\cacert.pem
CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Any help?
Related
I would like to send emails through a contact form in my Laravel 8 application. In my local instance everything works fine. When I upload it to the web server I receive the following error: 221 2.7.0 Error: I can break rules, too. Goodbye.
See screenshot of the error
My configuration
.env
MAIL_DRIVER=sendmail
MAIL_MAILER=sendmail
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=no-reply#example.de
MAIL_FROM_NAME="Example website contact form"
MAIL_RECIPIENT=my#email.de
Mail function in the contact controller
$toName = $request->name;
$toEmail = $request->email;
$toPhone = $request->phone;
$subject = $request->subject;
$message = $request->message;
if ($request->filled('phone')) {
$message = "Absender: $toName \nEmail: $toEmail \nTelefon: $toPhone" . "\n\n" . $message;
} else {
$message = "Absender: $toName \nEmail: $toEmail" . "\n\n" . $message;
}
// Send mail
Mail::raw($message, function ($message) use ($toName, $toEmail, $subject) {
$message->to(env('MAIL_RECIPIENT'))
->subject('Anfrage über das Kontaktformular')
->from($toEmail, $toName);
});
The message I can break rules, too. Goodbye. is emitted by the Postfix mail server when it received HTTP verbs (GET, POST, etc.) on an SMTP listener. If you're seeing this, it means you have an HTTP client attempting to talk to an SMTP server.
https://www.postfix.org/postconf.5.html#smtpd_forbidden_commands
I was sending email to a static email and it was working but when I tried to send to a dynamic user getting data from the DB it returned this error: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required"
my sending email function:
public function send_email()
{
$getStaff=DB::table('users')
->OrderBy('id','DESC')
->first();
$staffacckey=$getStaff->access_key;
$staffemail=$getStaff->email;
$valueurl = env('APP_URL');
$info = array();
$info['url']=$valueurl;
$info['name']='tinox';
$info['msg']='test';
$info['key']=$staffacckey;
Mail::send('email.mail',$info, function($email) {
$ghost='no-reply#domain.com';
$admin='System Administrator';
$email->from($ghost, $admin);
$email->to($staffemail)->subject('email confirmation');
});
}
public function send_email()
{
$getStaff=DB::table('staff')
->OrderBy('staff_id','DESC')
->first();
$staffacckey=$getStaff->access_key;
global $staffemail;
$staffemail=$getStaff->email;
$valueOne = env('APP_URL');
$info = array();
$info['url']=$valueOne.':8080';
$info['name']='tinox';
$info['msg']='test';
$info['key']=$staffacckey;
$info['email']=$staffemail;
Mail::send('email.mail',$info,
function($email)use ($info){
$ghost='no-reply#magazinelte.com';
$admin='System Administrator';
$email->from($ghost, $admin);
$email->to($info['email'])->subject('Account activation');
});
}
just fixed the issue!! Passed variables inside the Mail function and change my env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*******#gmail.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls
I am getting error when i am sending mail at gmail id,I am using laravel 5.7,
I am getting this errot
Call to undefined function App\Http\Controllers\send()
and my controller code is :
public function postEmail(Request $r)
{
$data=[
'user_email'=>$r->user_email,
'user_name'=>$r->user_name,
'user_phone'=>$r->user_phone,
'user_desc'=>$r->user_desc,
];
Mail:send('mail.mail', $data, function($user_desc) use($data)
{
$message->from('sumitsaoni#gmail.com', 'Send by Sumit');
$messge->to($data['sumit123#gmail.com']);
$message->subject($data['user_desc']);
});
return redirect()->back()->with('message','successfully data insertd');
}
And My Route is
Route::resource('contact', 'ContactController');
Route::post('/postEmail', 'ContactController#postEmail');
My .env file mail gmail: .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=my_email (Using my email id)
MAIL_PASSWORD=password (using my email id password)
MAIL_ENCRYPTION=tls
You should try this:
use Mail;
Mail::send('mail', $data, function($user_desc) use($data)
{
$message->from('sumitsaoni#gmail.com', 'Send by Sumit');
$message->to($data['user_email']);
$message->subject($data['user_desc']);
});
Updated answer
Mail::send('mail', $data, function($message) use($data)
{
$message->from('sumitsaoni#gmail.com', 'Send by Sumit');
$message->to($data['user_email']);
$message->subject($data['user_desc']);
});
change
Mail:send('mail.mail', $data, function($user_desc) use($data)
to
Mail::send('mail.mail', $data, function($user_desc) use($data)
try this one
Mail:send to replace Mail::send
After long searches in the forum, I can't find a helpful solution for my case.
I did alot of functions for sending emails in laravel and always that works fine.
This time, I got an error as you see below:
ErrorException in StreamBuffer.php line 95:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Here my .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:FMtA/k/okcPZB/HbWGbw5YiBM4EC3njxxLbgcdM1GrA=
APP_URL=http://localhost
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=myDB
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=suckerblood2010#gmail.com
MAIL_PASSWORD=<<Here_my_password>>
MAIL_ENCRYPTION=tls
MAIL_SENDER=Administration
Here my function to send the mail (in the controller Auth):
public function register(Request $request)
{
$this->validateLogin($request);
$token = hash('sha256', str_random(100) . time(), false);
$user = new User();
$user->email = $request->get('email');
$user->password = bcrypt($request->get('password'));
$user->remember_token = $token;
//$user->save();
$sent = Mail::send('auth.emails.createAccount', ['token' => $token], function ($m) use ($user) {
$m->from(getenv('MAIL_USERNAME'), getenv('MAIL_SENDER'));
$m->to($user->email, $user->email)->subject(config('constants.AccountCreated'));
});
if($sent == 1)
{
$msg = Lang::get('messages.EmailSent');
$this->showLoginForm($msg);
}
else
{
return redirect('/login')->withErrors([
'email' => Lang::get('messages.UserAddingError')
]);
}
}
I tried to change the protocol from tls to ssl, even the prot from 587 to 465
I have this problem only with this project and I can't understand why, despite all the searches I made...
Any suggestion please?
Thanks alot :)
Your root certificate is missing or corrupted, try installing one
# 1) Download a valid root ca
http://curl.haxx.se/ca/cacert.pem
# 2) Setup php.ini to point it
openssl.cafile=C:\php5\etc\cacert.pem
To make sure they are loaded, review this console command response
php -r 'var_dump(openssl_get_cert_locations());
You may need to restart your webserver
You can also disable ssl peer verification in php.ini, but it is not recommend (please don't do this in production!)
openssl.verify_peer 0
Useful docs: http://php.net/manual/migration56.openssl.php
I am doing project in laravel. I followed all the steps mentioned in
plivo.com .
As I had done same steps in my another old project and this worked perfectly, but after updating my composer its not working and throwing same error message as like my new laravel project. Error message is as follow,
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain
My Plivo folder is inside the root folder. Guzzle installed is "guzzlehttp/guzzle": "v6.1.1".
composer.json is,
{
"require": {
"plivo/plivo-php": "~1.1.0"
}
}
Controller.php
<?php
namespace App\Http\Controllers;
use Plivo;
public function signup(Request $request){
$number = $request->input('owner_phone');
$output = $this->validatenumber($number);
}
public function validatenumber($number){
$auth_id = "MAZJFKNTU3OGQ5NMM5YJ";
$auth_token = "NDcyYjU5NmMxMmQzMzYzMjIzODExMTg3NzZmOWVj";
$p = new Plivo\RestAPI($auth_id, $auth_token);
$params = array(
'src' => '14154847489', // Sender's phone number with country code
'dst' => '91'.$number, // Receiver's phone number with country code
'text' => 'Your TaaraGo verification code is '.$otpnumber. '.', // Your SMS text message
'url' => 'http://localhost/untitled/sentsms.php', // The URL to which with the status of the message is sent
'method' => 'POST' // The method used to call the url
);
return $response = $p->send_message($params);
}
?>
and route.php is,
Route::post('auth/signup', 'AuthController#signup');
Is there any solution to this problem? any one having same problem with laravel version 5.1.26, give me solution.