I am unable to fetch the emails from Office 365 mailbox using IMAP.
This used to work perfectly fine when we used to fetch the same from Gmail while now it is getting the following error:
Can't connect to 'hostname',port_number.
I got hostname by following this link => https://support.knowbe4.com/hc/en-us/articles/115006834408-How-To-Find-Your-Office-365-Host-Name
Please try use the /authuser method.
imap_open("{outlook.office365.com:993/imap/ssl/authuser=user#maindomain.com}", "user#maindomain.com", "password");
Related
I am making application that is a simple mail client. But when I try imap_open() for gmail account with valid password and username it says unvalid credetinals and I recieve mail tried to access from non secure medium in my gmail specified in the function imap_open() How can I make this function working in localhost?
Try a IMAP library available on github
I'm building a website, and part of it needs to send emails (one for account password reset links, the other for general user-admin contact). I've been using PearMailer to send emails through a GMail account, and that's worked fine...until now. For some reason, it's stopped sending emails, and it's giving me this very unhelpful error:
[message] => Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) (code: -1, response: )
openSSL is enabled, and all the credentials I'm using are correct (I can manually sign in to that GMail account using them).
This is the code I'm using, where $config holds the account credentials, and the $_POST data is from the Contact Us form (ignore the lack of sanitization on it while I'm developing):
require_once "Mail.php";
$params=array(
"host"=>"ssl://smtp.gmail.com",
"port"=>465,
"auth"=>true,
"username"=>$config["mailFrom"],
"password"=>$config["mailPass"]
);
$headers=array(
"To"=>$config["mailFrom"],
"From"=>$_POST['user']." <".$_POST["reply-to"].">",
"Content-type"=>"text/html",
"Subject"=>$_POST['subject']
);
$mail=Mail::factory("smtp", $params);
$sent=$mail->send($config["mailFrom"], $headers, htmlentities($_POST['body']));
It should be sending my GMail account an email from itself, but instead, it's giving me the error I mentioned above. After changing the to and from addresses, no matter what, it still gives me that error. Which is especially strange, since almost identical code is what I've been using to send password reset links, and that was working fine until just now; of course, it too is now failing to connect.
I can't find anything saying Google has changed its settings, and I absolutely haven't gone over the 2,000 messages per day limit that smtp.gmail.com is supposed to allow, so what's going on here?
My solution: switched from PearMailer to SwiftMailer, and in that, I'm setting the SSL options verify_peer and verify_peer_name to false using $transport->setStreamOptions. That seems to send mail just fine now. (Without those options disabled, apparently GMail's SSL certificates aren't compatible with newer versions of PHP. Go figure.)
EDIT:
I'm not really sure if this will work for you, try:
$params=array(
"host"=>"smtp.gmail.com",
"port"=>587,
"auth"=>true,
"username"=>$config["mailFrom"],
"password"=>$config["mailPass"]
);
This will use TLS instead of SSL. Give it a try.
In exchange environment I have PHP application setup to open and IMAP stream and parse emails. I have no problem connecting to my personal email account with the following:
imap_open("{exchange.server/ssl}INBOX", "username", "password");
Now I have been given access to a group email account and I'm wondering if its possible to specify other accounts with PHP's IMAP functions. I know when I setup outlook with a new profile I add the group email then my credentials with no problems.
I've also see telnet commands that support this in How can I access a shared Exchange mailbox with IMAP (over telnet)?
TELNET: ? LOGIN domain/username/mailboxname password
Using this logic I have tried:
imap_open("{exchange.server/ssl}INBOX", "username/sharedmailbox", "$password");
This gives an error I've also tried to add the domain with no luck.
Turns out I was very close with what I posted in the question however I was including #example.com for sharedmailbox#example.com in the imap_open(). Once I removed that I had no problem connecting with the following.
imap_open("{exchange.server/ssl}INBOX", "domain/username/sharedmailbox", "$password");
I'm trying to access my icloud mailbox from my website. The code I'm using works fine with gmail, but when I try to connect to my iCloud account i get this error:
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.mail.me.com:993/ssl/imap} in /hp/bd/ab/lq/www/rechner/Messages/MailAusgabe.php on line 6
and this is my code:
$mbox = imap_open("{imap.mail.me.com:993/ssl/imap}", "myemail#me.com", "mypassword");
and this aswell:
$mbox = imap_open("{imap.mail.me.com:993/ssl/imap}INBOX", "myemail#me.com", "mypassword");
I've already changed my password and tried some other accounts, but without success.
Try replacing this: "{imap.mail.me.com:993/ssl/imap}" by this: {imap.mail.me.com:993/imap/ssl}
i got a code from here to download gmail inbox:
http://davidwalsh.name/gmail-php-imap
use these 2 hostnames
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox
but getting this error.
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox in /home/medicalh/public_html/testmail.php on line 9
Cannot connect to Gmail: Can't connect to gmail-imap.l.google.com,993: Connection timed out
i have searched on stackoverflow but did't got solution
thanks
change you host name to this one and try
$hostname= '{imap.gmail.com:993/ssl/novalidate-cert}';
and double check the username and password
Open the php.ini file and remove ; before ;extension=php_imap.dll
and restart your server.
Your code will work...
You can download my Gmail class at my website: . I have also included a test file for you to test the class file.
If it does not work, I believe it could be your server's problem. You should contact your system administrator.
One of the issues with gmail IMAP SSL authentication is related to Google's account security.Once you get the login error once, sign out of all your google accounts. Then, visit this link:
https://accounts.google.com/DisplayUnlockCaptcha
Log in with the account you're attempting to access via imap.
Follow the steps and you'll then be able to login in to gmail with php imap.
It's visually shown here:
http://jeffreifman.com/filtered-open-source-imap-mail-filtering-software-for-php/configuring-gmail/
source: http://php.net/manual/en/function.imap-open.php