Hello,
I require your help to solve a problem; It turns out that I want to send an email, and I get an error “SMTP Timeout”. It should be noted that I have the application in a hosting of Godaddy. I attach the configuration.
// app.php
'EmailTransport' => [
'default' => [
'className' => 'Mail',
// The following keys are used in SMTP transports
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => null,
'password' => null,
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
'laboralmedicmail'=>[
'className' => 'Smtp',
'host' => 'a2plcpnl0421.prod.iad2.secureserver.net',
'port' => 465,
'timeout' => 30,
'user' => 'info@laboralmedic.com',
'password' => '********',
'tls' => true,
],
],
/**
* Email delivery profiles
*
* Delivery profiles allow you to predefine various properties about email
* messages from your application and give the settings a name. This saves
* duplication across your application and makes maintenance and development
* easier. Each profile accepts a number of keys. See `Cake\Mailer\Email`
* for more information.
*/
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'you@localhost',
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
'laboralmedicMail-profile' => [
'transport' => 'laboralmedicmail',
'from' => 'info@laboralmedic.com',
'charset' => 'utf-8'
],
],
// my controller
public function sendmail()
{
$msg='Estimado;Se le comunica que se le ha programado el examen médico en la clínica';
$subject='Programación de Examen Médico';
$to='vito2100@gmail.com';
$true=$this->sendUserEmail($to,$subject,$msg);
if($true=='1')
{
$this->Flash->success(__('Mail Send'));
return $this->redirect(['action' => 'index']);
}
else
{
$this->Flash->success(__('Error'));
return $this->redirect(['action' => 'index']);
}
}
public function sendUserEmail($to,$subject,$msg)
{
$email = new Email();
$email
->transport('laboralmedicmail')
->from(['info@laboralmedic.com' => 'info@laboralmedic.com'])
->to($to)
->subject($subject)
->emailFormat('html')
->viewVars(array('msg' => $msg))
->send($msg);
return 1;
}
Please, I am against the time since I need to deliver the application, I hope you can help me. Thank you so much.