I have cakephp application, and it has no domain name we are accessing using ip.
I am using the following smpt setting to send email
class EmailConfig {
public $smtp = array(
'transport' => 'Smtp',
'from' => array('myemail#otherdomain.com' => 'my name'),
'host' => 'mail.otherdomain.com',//not the same domain from which sending email
'port' => 25,
'timeout' => 30,
'username' => 'myemail#otherdomain.com',
'password' => 'password',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
all emails are being sent to any_email # gmail, otherdomain etc
but there is only one specific govt domain(abc.gov.com) who are not receiving email
they may have implemented some security measures, which may prevent my emails to them, what things can I try at my side and how can I debug to get exact error.
I tried to send email where
to = email#abc.gov.com
cc = email#otherdomain.com
the same email is being received by email#otherdomain.com while not by email#abc.gov.com
Related
I'm trying to use cakephp to send e-mail from my users, but I want each user uses they own e-mail for example
my app config
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'username' => 'formulariosdsds#gmail.com',
'password' => '***',
'tls' => true,
],
it's used for App e-mais like, accont recovery and registration.
I want the users send with they own e-mail using the app like a transporter for each user. is there a way to do it?
Sure, you have to create a configuration transport each time a user send an email.
$transport = $user_data_email_config;
// first you drop to prevent to add a configuration pre existing and generate an error
Email::dropTransport($transport->name);
// now you create a custom configuration
Email::configTransport($transport->name, [
'className' => $transport->class_name,
'host' => $transport->host,
'port' => $transport->port,
'timeout' => 30,
'username' => $transport->username,
'password' => $transport->password,
'client' => $transport->client,
'tls' => $transport->tls
]);
$Email = new Email();
// for use the custom configuration, set the transport providing the transport name when you configure the email.
$Email->transport($transport->name);
// the rest of email configuration...
I had written following code to send email.
static function sendEmail($email,$data,$type){
$Email = new CakeEmail();
$Email->config('general');
switch($type){
case 1:
$Email->template('confirmation_free', null);
$Email->subject('Confirmation of registration with XXXXXXXXXXXXX');
$Email->viewVars(array('Email'=>$data["Email"],'full_name'=>$data['full_name'],'Id'=>$data['Id'],'url'=>$_SERVER['SERVER_NAME'], 'password'=>$data['password']));
break;
case 2:
$Email->template('group-invite', 'default');
$Email->subject('XXXXXXXX Group Invite - Notification');
$Email->viewVars(array('Email'=>$data["Email"],'Username'=>$data['Username'],'Id'=>$data['Id'],'url'=>$_SERVER['SERVER_NAME']));
break;
case 3:
$Email->template('forgot_password', null);
$Email->subject('XXXXXXXX - Forgot Password');
$Email->viewVars(array('Email'=>$data["Email"],'Key'=>$data['Key'],'url'=>$_SERVER['SERVER_NAME'],'Id'=>$data['id']));
break;
}
$Email->to($email);
if($Email->send())
return true;
else
return false;
}
with following sendgrid smtp settings.
public $general = array(
'transport' => 'Smtp',
'from' => array('XXXXX#XXXXXXX' => 'XXXXXX Administrator'),
'host' => 'smtp.sendgrid.net',
'port' => 587,
'timeout' => 30,
'username' => 'XXXXXXX',
'password' => 'XXXXXX',
'client' => null,
'log' => false,
'emailFormat' => 'html'
);
It was working perfectly fine on my local and dev server. But after we installed SSL on the dev server, it started throwing following error "SMTP server did not accept the password "
Please note that I'm using a sendgrid free account. Do I need a paid account to send emails from a server with SSL?
You need to either use the tls option in your CakeEmail config or prefix the host with ssl:// https://book.cakephp.org/2.0/en/core-utility-libraries/email.html
Xylon, Please try this.
In Email.php
public $smtp = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'your email',
'password' => 'password',
'transport' => 'Smtp',
'log' => true,
'auth' => true,
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
$Email = new CakeEmail('smtp'); // In Controller where you want send mail
$Email->viewVars(array("data" => $data));
$Email->template($template)
->emailFormat('html')
->to($reciever)
->from(array($mail_from => "Ecotrak"))
->subject($subject)
->send();
I hope this will resolve problem.
Email could not be sent: SMTP server did not accept the password. See trace
If you are facing that issue and your check everything is fine there is no issue anywhere but you still facing that issue.
Just do this simple process.
Go to your Google Account.
Select Security.
Go down
Click on Less Secure app access
Turn it on
Now check it... your issue will resolve
I'm using 1and1 server to host my CakePHP 3.2 application
This is how, I have configured email component on CakePHP
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
// The following keys are used in SMTP transports
'host' => 'smtp.1and1.com',
'port' => 587,
'timeout' => 30,
'username' => 'noreply#mywebsite.com',
'password' => 'password',
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
But this is not working and no email is sent and gives Connection Time out after 30 seconds.
From 1and1 email configuration page. It says
Outgoing port (TLS must be activated)
How to enable/configure TLS in CakePHP ?
Edit 2
the error stack shows
SmtpTransport.php
protected function _connect()
{
$this->_generateSocket();
if (!$this->_socket->connect()) { // marked this line
throw new SocketException('Unable to connect to SMTP server.');
}
$this->_smtpSend(null, '220');
Action to send email
public function sendEmail($user_id = null, $email_id = null, $hash = null, $request = null)
{
switch($request) {
case 'register' : $subject = 'Account Confirmation';
$message = 'You have successfully registered. Click below link to verify it http://website.com/sellers/verify/'.$email_id.'/'.$hash;
break;
}
$email = new Email('default');
if ($email->from(['anujsharma9196#gmail.com' => 'Argo Systems'])
->to((string)$email_id)
->subject($subject)
->send($message)) {
return true;
} else {
return false;
}
}
and calling this function from same controller by
$this->sendEmail($user->id, $user->email, $hash, 'register');
from the manual (bold is mine)
You can configure SSL SMTP servers, like Gmail. To do so, put the ssl:// prefix in the host and configure the port value accordingly. You can also enable TLS SMTP using the tls option:
so just set
'tls' => true
in your configuration array and try if it works
Edit
following this page I found that you don't even need to use the Smtp transporter
just use a simple Mail transporter this way
'default' => [
'className' => 'Mail'
]
There is no need to supply a username, password, or specify which mail server should be used to send the mail since this information is already contained in PHP variables.
try that!
I used below configuration in system for mail using gmail. it work fine. you just try with your server.
'EmailTransport' => [
'default' => [
'className' => 'SMTP',
// The following keys are used in SMTP transports
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 100,
'username' => 'example#gmail.com',
'password' => 'exmple123',
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
Check with your port and host.Hope fully it will works
Try
Thanks
This is the sample email I received
This is my code:
Laravel 4.2
Controller:
Mail::send('emails.patient.fax-note'){
$message->to('61756041159#efaxsend.com');
$message->to('sunnycris1229#gmail.com', "Sunny");
$message->subject('Test Fax Notes Using smtp.mailgun.org');
$message->from('support#lktconsult.com');
} , "-f support#lktconsult.com");
mail.php setting
'driver' => 'mailgun',
'host' => 'smtp.mailgun.org',
'port' => 587,
'from' => array('address' => "support#lktconsult.com", 'name' => "Hippocamp"),
'encryption' => 'tls',
'username' => "support#lktconsult.com",
'password' => "mypassword",
services.php
'mailgun' => array(
'domain' => 'sandbox9a694deec43645249032794f0b054c82.mailgun.org',
'secret' => 'my key here',
),
My Code works perfectly in the email, but not in efax, because efax only accept the mail if you send it to :61756041159#efaxsend.com and most importantly from: support#lktconsult.com , My problem is, the image I attached is the original email I received in my gmail.. stating that it came from : Received: from mail1.static.mgsend.net (mail1.static.mgsend.net. [104.130.122.1]) thats why efax does not accept the email.
I am developing an application where my client is using Office 365 for his emails , etc... I am trying to connect Cakephp mail with office 365 SMTP but without any success.
Here is my code:
public $default = array(
'from' => array('info#*****.com' => 'Company Name'),
'transport' => 'Smtp',
'host' => 'tls://smtp.office365.com',
'port' => 587,
'username' => 'info#*****.com',
'password' => '*******',
'client' => null,
'log' => true,
'tls' => true
);
The error iam getting is Unable to connect to SMTP server. Also I tried the following hosts with and without tls:
ssl://smtp-mail.outlook.com
Smtp.mail.apac.microsoftonline.com (on this i was getting timeout error)
pod51022.outlook.com
Thanks.
try following :
'public $default = array(
'host' => 'smtp.office365.com',
'port' =>25,
'from' => array('info#*****.com' => 'Company Name'),
'transport' => 'Smtp',
'username' => 'info#*****.com',
'password' => '*******',
'tls'=>true );'
in case it don't work,
try after removing password,
make sure that
email id is authenticated to send anonymous mail on office365.