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);
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
),
)
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');
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..!
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.
I connect to a remote database from within my symfony2 app with this code
$connectionFactory = $this->container->get('doctrine.dbal.connection_factory');
$conn = $connectionFactory->createConnection(array(
'driver' => 'pdo_mysql',
'user' => 'mattias',
'password' => 'fdfsdf',
'host' => 'fs1.rrtgy.se',
'dbname' => 'csmedia',
));
return $conn;
Is there a parameter I can set to do it using SSL?
The equivalent of something like this:
$link = mysql_connect("192.112.7.18","test","testpass",false,MYSQL_CLIENT_SSL)
You could try add to createConnection array 'driverOptions'
$conn = $connectionFactory->createConnection(array(
'driver' => 'pdo_mysql',
'user' => 'mattias',
'password' => 'fdfsdf',
'host' => 'fs1.rrtgy.se',
'dbname' => 'csmedia',
'driverOptions' => array(
PDO::MYSQL_ATTR_SSL_CA =>'/path/to/ssl-ca.pem'
),
));
More info about MYSQL SSL constants.
Notice, that some constants were added at php 5.3.7
However, SSL options are silently ignored in (at least) version 5.3.8: see the bug report.