Hello Everyone,
I am trying to send email through cakephp framework,but unfortunately email are not getting delivered. But when i use social email service provider such as google, outlook and rediffmail e-mail gets delivered.
My SMTP port is 465. I am using below cakephp mail()function:
public $gmail = array(
'host' => 'ssl://smtp.techphant.com',
'port' => 465,
'username' => 'xyz#abc.com',
'password' => 'xxxxxx',
'transport' => 'smtp',
);
Also i have tried port number 2525 and 25 but to no avail.
Please let me know your suggestions.
Thanks in advance.
Try to send eamil with cake Email component not with mail() function.
$this->set(
'content',
'<h1>Hi </h1>
<p>Thanks for contact us. We will respond you soon</p>
'
);
$this->Email->smtpOptions = array(
'host' => 'ssl://smtp.techphant.com',
'port' => 465,
'username' => 'xyz#abc.com',
'password' => 'xxxxxx',
'timeout' => 30,
'client' => null
);
$this->Email->to = 'abc#gmail.com';
$this->Email->subject = 'Thanks for contact us';
$this->Email->from = 'no_reply#abc.com';
$this->Email->template = 'default';
$this->Email->sendAs = 'html';
$this->Email->send();
Thanks..!
Related
I get the following error on my cakePHP2.7 project when I move the code to my new server. The code works fine on all my existing servers.
we are using aws SES as mail service.
We created a sample file as instructed by https://docs.aws.amazon.com/ses/latest/dg/send-using-smtp-programmatically.html and that also works fine.
Any help is appriciated
code for your reference
public $mailarr = array(
'host'=>'email-smtp.us-west-2.amazonaws.com',
'port' => 587,
'username' => 'XXXXXXXXXXXXXXX',
'password' => 'XXXXXXXXXXX',
'tls'=>true,
'returnPath'=>'xxx#xxx.com',
'transport' => 'Smtp',
'from' => array('xxx#xxx.com' => 'Alert!'),
'emailFormat' => 'html',
'timeout' => 300,
);
I have tried to add the below as part of my mailarr but the error still persists
'context' => array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
),
)
Not all users in LDAP are authorized to own an user account in my MediaWiki. I already have users logging in because I created their accounts before installing LDAP Plugin. Now, I need to create accounts for new employees and I always receive the message "Username entered already in use. Please choose a different name.", through Special:CreateAccount.
Obviously, If I disable all LDAP configuration in LocalSettings, I'm able to create a local user account with the same LDAP username. Then , if I enable LDAP configuration again, the user is recognized with LDAP password and he can log in. The fact is that I don't want to edit LocalSettings every time I have a new employee.
MediaWiki: 1.29.1
PHP: 5.5.21 (apache2handler)
PostgreSQL: 9LDAP
My configuration is below. Thanks in advance.
require_once ('.../extensions/LdapAuthentication/LdapAuthentication.php');
$wgAuth = new LdapAuthenticationPlugin();
$wgLDAPDomainNames = array( 'AD' );
$wgLDAPServerNames = array( 'AD' => 'url' );
$wgLDAPUseLocal = false;
$wgLDAPEncryptionType = array( 'AD' => 'clear' );
$wgLDAPPort = array( 'AD' => 389 );
$wgLDAPProxyAgent = array( 'AD' => 'CN=a,OU=b,DC=c,DC=d' );
$wgLDAPProxyAgentPassword = array( 'UFPE-AD' => 'password' );
$wgLDAPSearchAttributes = array( 'AD' => 'description' );
$wgLDAPBaseDNs = array( 'AD' => 'DC=c,DC=d' );
$wgLDAPDisableAutoCreate = array( 'AD' => true );
$wgLDAPPreferences = array( 'AD' => array( 'email' => 'mail', 'realname' => 'cn','nickname' => 'givenname') );
$wgLDAPLowerCaseUsername = array( 'AD' => true);
$wgGroupPermissions['*']['createaccount'] = false;
I want to use my email on my server with CakePHP IMAP Custom Datasource.
In database.php I have:-
public $myCustomEmail = array(
'datasource' => 'ImapSource',
'server' => 'test.com',
'username' => 'info#test.com',
'password' => 'email password',
'port' => 143,
'ssl' => true,
'encoding' => 'UTF-8',
'error_handler' => 'php',
'auto_mark_as' => array(
'Seen',
// 'Answered',
// 'Flagged',
// 'Deleted',
// 'Draft',
),
);
When I set port to 143 or ssl to true I get this error:-
Error: Unable to get imap_thread after 4 retries. 'TLS/SSL failure for radindesign.com: SSL negotiation failed'
When ssl is set to false or I change the port I get this error:-
Unable to get imap_thread after 4 retries. 'Certificate failure for test.com: self signed certificate: /CN=linux10.centraldnserver.com/emailAddress=ssl#linux10.centraldnserver.com'
What's wrong with the IMAP authentication?
CakePHP IMAP Custom Datasource didnt help me i use from this :
// Configure your imap mailboxes
$mailboxes = array(
array(
'label' => 'Gmail',
'mailbox' => '{imap.gmail.com:993/imap/ssl}INBOX',
'username' => 'yourusername#gmail.com',
'password' => 'yourpassword'
),
array(
'label' => 'My Cpanel website',
'mailbox' => '{mail.yourdomain.com:143/notls}INBOX',
'username' => 'info+yourdomain.com',
'password' => 'yourpassword'
),
array(
'label' => 'Another mail account',
'mailbox' => '{mail.yourdomain.com:143/notls}INBOX',
'username' => 'info#yourdomain.com',
'password' => 'yourpassword'
)
);
//check inbox
$current_mailbox = array(
'label' => 'My Cpanel website',
'mailbox' => '{mail.test.com:143/notls}INBOX',
'username' => 'info#test.com',
'password' => '***'
);
// Open an IMAP stream to our mailbox
$stream = #imap_open($current_mailbox['mailbox'], $current_mailbox['username'], $current_mailbox['password']);
$emails = imap_search($stream, 'SINCE ' . date('d-M-Y', strtotime("-1 week")));
// If we've got some email IDs, sort them from new to old and show them
rsort($emails);
$i = 0;
$overview = array();
foreach ($emails as $email_id) {
// Fetch the email's overview and show subject, from and date.
$overview[$i] = imap_fetch_overview($stream, $email_id, 0);
$i++;
}
var_dump($overview);
I have the following function being called from my view.ctp file after a form button is pressed. However nothing is being recieved. Any advice?
public function email(){
// ============Email================//
/* SMTP Options */
$this->Email->smtpOptions = array(
'port' => '465',
'timeout' => '30',
'host' => 'ssl://smtp.gmail.com',
'username' => 'email1#gmail.com',
'password' => 'password1',
'transport' => 'Smtp'
);
// sending/receiver details for email
$this->Email->template = 'resetpw';
$this->Email->from = 'Cafe <email1#gmail.com>';
$this->Email->to = 'Andrew <email2#gmail.com';
$this->Email->subject = 'Junto Cafe: Password reset';
$this->Email->sendAs = 'both';
$this->Email->delivery = 'smtp';
$this->set('ms', $ms);
$this->Email->send();
$this->set('smtp_errors', $this->Email->smtpError);
// after sending, display a notification
$this->Session->setFlash(__('Check Your Email To Reset your password', true) , 'alert-box', array(
'class' => 'alert-success'
));
// ============EndEmail=============//
}
Solved. Forgot to add
App::uses('CakeEmail', 'Network/Email');
In my model I'm sending an email once the User is created:
Model/User.php:
<?php
App::uses('AppModel', 'Model');
App::uses('CakeEmail', 'Network/Email');
class User extends AppModel {
...
private function sendWelcomeMail($name, $email, $password) {
$Email = new CakeEmail('smtp');
$Email->viewVars(array('name' => $name, 'password' => $password));
$Email->template(('welcome'));
$Email->emailFormat('html');
$Email->from(array('info#staycomputer.de' => 'Stay Computer'));
$Email->to($email);
$Email->subject('Stay Serviceordersystem: Willkommen / Welcome');
$Email->send();
}
}
Config/email.php:
public $smtp = array(
'transport' => 'Smtp',
'from' => array('info#***.de' => 'Stay Computer'),
'host' => '***',
'port' => 25,
'timeout' => 30,
'username' => '***',
'password' => '***',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
It's working fine on my testing system but not on production system (1&1 webhosting):
Error: An Internal Error Has Occurred.
According to error.log:
Error: [SocketException] Connection timed out Request URL ...
and
15:52:36 Error: Fatal Error (256): [CakeException] Unknown status code #0 /homepage/30/d20974062/htdocs/StaywebDB/serviceordersystem/lib/Cake/Error/ExceptionRenderer.php(212) ...
There is only 1 difference:
In production system I use the built in re-writing function.
Switching to gmail worked like a charm. Thanks for the recommondations.