I was pulling my inboxes using php-imap/php-imap library and inboxes managed by CPanel. All in sudden script stopped with following error.
Connection error: Certificate failure for imap.domain.com:
Server name does not match certificate:
/OU=Domain Control Validated/OU=PositiveSSL/CN=<amazon.domain.com>
in /.../vendor/php-imap/php-imap/src/PhpImap/Mailbox.php
here is the imap path I am using:
{imap.domain.com:143/imap/tls}INBOX
I also tried {imap.domain.com:143/novalidate-cert/imap/tls}INBOX but all in vain.
What change could have have stopped it?
How to fix it and avoid such failure in future?
IMAP port is 993..143 for POP..Try it..
{imap.domain.com:993/imap/ssl/novalidate-cert}INBOX
Related
When using PHPMailer to send emails, I'm encountering a CN error with the message "ErrorException (E_WARNING) stream_socket_enable_crypto(): Peer certificate CN=`sinaisdeforex.com' did not match expected CN." What does this error mean, and what is causing it? How can I resolve the error and successfully send email using PHPMailer? Are there any specific configuration changes or certificate updates that I need to make to ensure that the correct CN is being used when connecting to the email server?
I have a problem with PHPMaile and SMTPMailer on my LARAVEL site to use Amazon SES SMTP email provider. Try to resolve or troubleshoot credential deletion and create a new method-paid credential rather than resolution. Contact Amazon Support and I was informed: the upload request is failing validation on the PHP side. When you enter my site https://sinaisdeforex.com/contact-us click the button: SEND MESSAGE is reported or error:
ErrorException (E_WARNING)
stream_socket_enable_crypto(): Peer certificate CN=`sinaisdeforex.com' did not match expected CN=`email-smtp.us-east-1.amazonaws.com'
This is covered in the troubleshooting guide.
You have the Host property in PHPMailer set to sinaisdeforex.com, but the mail server you are connecting to is not responding with a certificate that matches that name, so it's presumably an alias. Fix this by changing the name of the Host you're connecting to to one which matches the certificate, such as email-smtp.us-east-1.amazonaws.com.
I am using PHP's imap_open function to connect to an IMAP email server. This has been working fine for several years, but the email server was recently changed and I have started getting the following error:
"Cannot connect to mail server: Certificate failure for
subdomain.mail.domain.com: Unable to locate common name in
certificate"
The email server's tech support responded:
"The common name for our cert is "*.mail.domain.com". As it is a wildcard certificate, there is no explicit hostname for it. It appears that your scripts are expecting the certificate to return explicitly for "subdomain.mail.domain.com" when our wildcard certificate will not. This is why the error above occurs."
If I disable SSL certificate checking using the /novalidate-cert flag in the imap_open function I'm able to connect, but I'd obviously prefer to keep certificate validation enabled. Is there a way to do this with wildcard certificates and the imap_open function?
I have enabled OpenSSL and IMAP functions from my php.ini file and phpinfo() confirms it.
By using the code below i can connect to a Hotmail account but not to a Gmail account.(of course i change the $connect_to to point to Hotmail.)
$connect_to = '{imap.gmail.com:993/imap/ssl}INBOX';
$connection = imap_open($connect_to, $user, $password)
or die("Can't connect to '$connect_to': " . imap_last_error());
imap_close($connection);
The returned error is
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /opt/lampp/htdocs/webmail_client_practise/index.php on line 6
Can't connect to '{imap.gmail.com:993/imap/ssl}INBOX': Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
Notice: Unknown: Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA (errflg=2) in Unknown on line 0
Unfortunately i cannot find a complete tutorial of how to use the IMAP functions.
Any ideas, solutions or suggestions will be helpful.
UPDATE:
After searching for my problem on the Internet, i did not found a solution that solves my problem completely. Although if
1) I use the insecure $connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
2)And allow gmail to be accessed by less secured apps,
solves my problem for now.
Please check this https://support.google.com/accounts/answer/6010255?hl=en
If you get blocked, this can be because google sees a login from a new device.
Go to your google account and check
https://myaccount.google.com/device-activity
and let them know the 'Unknown device is ok to use'.
First check your date and time settings on your server are correct.
Alternatively try:
$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX',
This will stop it from trying to validate certificate.
I will probably get downvotes from people telling me this is bad practice as this leaves you open to Man in the Middle attacks. Which is true.
I've been using class.phpmailer.php for some time but recently it stop working on my web server.
It is still working on my home computer but I guess that it's because I didn't update xampp.
The error returned is:
php SMTP -> ERROR: Failed to connect to server: 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. (10060)
I've also used this class eukhost and it sends the email with no errors.
I'm now going debugging class.phpmailer.php to see what is wrong.
But before I start, I would like to know if someone got this problem ans solved it.
If this had been working and now has recently stopped, it could be a temporary issue, or some settings for the mail server have been changed and you now need to update your settings.
The error message is telling you that it could not connect to the mail server. Socket error 10060 is a general operation timed out message.
You need to verify that the SMTP host and port numbers being used by phpmailer are correct. You should from another machine (or the same system running PHP) be able to telnet your-mail-server-here.com 25 where 25 represents the port number.
If you can't connect to the server, then the mail server is down or the hostname or port have changed. If you can connect from other systems but not from your PHP server, it is possible your IP has been blocked from the mail server, or a local/remote firewall are preventing your connection.
Hope that helps.
ive been looking online for hours for solution in this problem of mine.
I just simply would like to send emails using gmail smtp, php, and swiftmailer
I am using kohana for this. Xampp 1.7.4. At first, it displays an error about ssl not being configured in php. I googled and added a new line in php.ini, that is (extension = php_openssl.dll), and pasted two dll files from php folder to apache bin folder (libeay32.dll and ssleay32.dll). but to no avail, it still wont allow me to send emails..
Here's the error being displayed, i cant find similar problems online... anyone pls. help.
Swift_ConnectionException
C:/xampp/htdocs/gbs/system/vendor/swift/Swift/Connection/SMTP.php [309]:
The SMTP connection failed to start [ssl://smtp.gmail.com:465]: fsockopen returned Error Number 0 and Error String ''
Stack Trace
* system\vendor\swift\Swift.php [216]:
Swift_Connection_SMTP->start( )
* system\vendor\swift\Swift.php [101]:
Swift->connect( )
* system\helpers\email.php [103]:
This is just a wild guess based on a similar problem I had, so I could be that it has nothing to do with it.
What I'm thinking is that somewhere you have to give the path to the root certificat authority file.
On my computer it is located in /etc/ssl/certs/ca-certificates.crt, but you will have to find out where it is on your computer/server. Now the problem is finding out how you can pass that on through swiftmailer.
Another thing the make sure is in the swiftmailer documentation:
For SSL or TLS encryption to work your PHP installation must have appropriate OpenSSL transports wrappers. You can check if "tls" and/or "ssl" are present in your PHP installation by using the PHP function stream_get_transports()