forked from QuentinCG/OVH-Email-Manager-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimap_utility.php
41 lines (35 loc) · 911 Bytes
/
imap_utility.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
* \brief IMAP utility functions
*
* \author Quentin Comte-Gaz <[email protected]>
* \date 18 July 2016
* \license MIT License (contact me if too restrictive)
* \copyright Copyright (c) 2016 Quentin Comte-Gaz
* \version 1.0
*/
?>
<?php
/*!
*@function canLoginEmailAccount Check email credential validity
*@param imap_server (string) Imap server (host or IP)
*@param email (string) Email login
*@param password (string) Email password
*@return (boolean) Can connect to the email account in the imap server
*/
function canLoginEmailAccount($imap_server, $email, $password)
{
// Open Imap connection
try {
$mbox = @imap_open('{'.$imap_server.':143}INBOX', "$email", "$password");
if (!$mbox) {
return false;
}
// Close IMAP connection if it was correctly opened
imap_close($mbox);
return true;
} catch (Exception $e) {
return false;
}
}
?>