cakeEmail getaddrinfo failed: No such host is known - php

I'm trying to send an email in cakephp (no need to use ssl at the time), config seems fine but I keep getting the error above, below is my smtp config:
public $smtp = array(
'transport' => 'Smtp',
'from' => array('test#mambihost.com' => 'Mambihost'),
'host' => 'mail.mambihost.com ',
'port' => 26,
'timeout' => 100,
'username' => 'test#mambihost.com',
'password' => 'secret',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
Why could this be happening? I'm running this in a wamp on my server which is inside a LAN. I can ping the host from the server with no problem but my app doesn't seem to reach it or something.
Could you help me please?

Related

Getting error while trying to send email in localhost php

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
app.php
'EmailTransport' => [
'default' => [
//**'className' => MailTransport::class,
/*
* The following keys are used in SMTP transports:
*/
'host' => 'ssl://smtp.gmail.com',
'port' => 567,
//'timeout' => 30,
'username' => 'abc#gmail.com',
'password' => 'abc',
'className' => 'Smtp',
// 'client' => null,
'tls' => true,
//'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'abc#gmail.com',
],
],
Controller class
public function mail()
{
$session = $this->request->session();
$id = $session->read('req_id');
$email = new Email();
$email->transport('default');
$email->from(['NO-REPLY.formcr1#abc.com.au' => 'abc REPLY']);
$email->sender(['NO-REPLY.formcr1#abc.com.au' => 'abc NO-REPLY']);
$email->to('abc#gmail.com'); /** This must be changed to abc's confirmed email */
$email->subject('abc Request Number : '.$id);
//THIS PATH NEEDS TO BE CHANGED DURING DEPLOYMENT
$path = 'C:/xampp/htdocs/request_form/webroot/pdfresults/';
$email->attachments($path. 'abc Cost Estimate Request Information_'.$id.'_'.'v.3online'.'.pdf');
$email->send('Please look for the attachment to see the form. Cheers!');
}
enter image description here
email credential are correct. and tried turning off the firewalls as well but still not working
The error means exactly what it says - the service you’re trying to connect to doesn’t exist or is not responding.
This is explained two ways. Either the service you’re connecting to is indeed down, or you’re trying to connect to the wrong server or port.
In this case, it’s the latter. You’re trying to connect to an implicit TLS SMTP service on a port not associated with that service.
Change this:
'host' => 'ssl://smtp.gmail.com',
'port' => 567,
To
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
Or
'host' => 'tls://smtp.gmail.com',
'port' => 587,

cant send an email on cakephp3

I can't get cakephp3 to send emails. In cakephp2 I could do this no problem. I am using the latest WAMP, and cakephp3.3 on Windows 7. I tried to follow the directions but it looks like I am getting something basic wrong. Do I also need to configure Wamp as I checked the php.ini-development file but there is no smtp entry to change
error- stream_socket_client(): SSL operation failed with code 1.
OpenSSL Error messages: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
stream_socket_client(): Failed to enable crypto
stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465
(Unknown error)
controller
public function singleTutorEmail(){
$email = new Email();
$email->transport('gmail3');
$to='jjxxx#gmail.com';
$subject='testing';
$message='hello, dfsfsdfsdf sdfsdf';
$email->from(['jjxxx#gmail.com' => 'test'])
->to($to)
->subject( $subject)
->send($message);
}
in app.php
'EmailTransport' => [
'default' => [
'className' => 'Mail',
// The following keys are used in SMTP transports
'host' => 'localhost',
'port' => 465,
'timeout' => 30,
'username' => 'user',
'password' => 'secret',
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
'gmail3' => [
'className' => 'Smtp',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'jjxxx#gmail.com',
'password' => 'xxx',
'client' => null,
'context' => [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]
],
],
http://book.cakephp.org/3.0/en/core-libraries/email.html
Sending Mail using CakePHP 3.0
I had the same issue when making an HTTPS request using Cake\Network\Http\Client
To resolve the problem, I had to download "cacert.pem" file from https://curl.se/ca/cacert.pem
And then I updated php.ini by adding the following line:
openssl.cafile = <PATH_TO_CACERT_PEM>/cacert.pem
Don't forget to restart the web-server.
If the above thing doesn't make it work, try to update the OpenSSL library installed on your system.
I really hope this works for you too.

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

I just developed a laravel web application with mail system.
i got error like
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
controller
Mail::send('timesheet/emailtemplate',array('data'=>$query),function($message)
{
$message->to('example#gmail.com')->cc('expalecc#gmail.com')->subject('Work Report on - ');
});
email template file : emailtemplate.blade.php
<h2>hai</h2>
mail.php (config)
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => null, 'name' => null),
'encryption' => 'ssl',
'username' => 'myemail#example.com',
'password' => 'mypassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
instead of using smtp use Mandrill Driver it is simpler and quicker than use smtp server. by default laravel comes with Mandrill Driver. mandrill required Guzzle 4 HTTP library.. for geting that into your project add
"guzzlehttp/guzzle": "~4.0"
to your composer.json file (in your project root directory)
inside app/config/mail.php
change this line
'driver' => 'mandrill',
go to https://mandrillapp.com/settings
and sign up and generate api key
create an app/config/services.php configuration file if one does not already exist for your project and add below configurations and generated api key
return array(
'mailgun' => array(
'domain' => '',
'secret' => '',
),
'mandrill' => array(
'secret' => 'enter your mandrill api key here',
),
'stripe' => array(
'model' => 'User',
'secret' => '',
),
);
check this out this will be help full
Youtube video for setting up Mandrill for laravel

How do I setup Cakephp email?

I was wondering about getting this cakephp email thing to work. I have not much knowledge but was wondering what I would need to use. I will be using my website email for this so something like admin#website.com but It is able to log in through gmail because it is setup that way. Thank you.
<?php
class EmailConfig {
public $mail = array(
'transport' => 'Mail',
'from' => 'test#test.com',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
public $smtp = array(
'transport' => 'Smtp',
'from' => array('site#localhost' => 'My Site'),
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => 'user',
'password' => 'secret',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'test#test.com',
'password' => 'myPass',
'transport' => 'Smtp'
);
public $fast = array(
'from' => 'you#localhost',
'sender' => null,
'to' => null,
'cc' => null,
'bcc' => null,
'replyTo' => null,
'readReceipt' => null,
'returnPath' => null,
'messageId' => true,
'subject' => null,
'message' => null,
'headers' => null,
'viewRender' => null,
'template' => false,
'layout' => false,
'viewVars' => null,
'attachments' => null,
'emailFormat' => null,
'transport' => 'Smtp',
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => 'user',
'password' => 'secret',
'client' => null,
'log' => true,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
Here is an example config that works for Gmail / Google Apps hosted emails. You'll obviously need to fill it in with your own email address and password.
class EmailConfig {
public $default = array(
'transport' => 'Smtp',
'from' => array('example#domain.com' => 'Joe Bloggs'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'example#domain.com',
'password' => 'YOUR_GMAIL_PASS_GOES_HERE'
);
}
Unless there's a specific SMTP server you wish to connect to, to send email, you don't need to change the default email.php. Just make sure you include a from() and to() in your call.
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->from(['noreply#host.com' => 'No Reply'])
->to('recipient#otherhost.com')
->subject('My subject')
->send('The body of the email');
Just using the default config will use whatever mail functionality you have set up in PHP. On a UNIX box, the machine will usually be set up to relay mail. On a Windows machine, you may need to set up a mail relay, unless it is an SMTP server.
If it's your development environment and Windows, then I would recommend setting up smtp4dev. smtp4dev is a very handy tool that listens on port 25, and behaves like an SMTP server. This will ensure that any locally generated emails from your development environment do not make it to the outside world.

CakePHP 2 - CakeEmail Proxy Settings

I am using CakePHP2 and the default Email Config is as below
public $smtp = array(
'transport'=> 'Smtp',
'from' => array('emailaddress'=> 'displayname'),
'host' => 'serveraddress',
'port' => 25,
'timeout' => 30,
'username' => 'username',
'password' => 'password',
'client' => null,
'log' => TRUE,
'delivery'=> 'smtp'
);
However, i would wish to define a proxy server for sending this e-mails.
Can anyone help me defining Proxy Server for sending E-Mails or can i configure a proxy server for all Cake Requests?

Categories