PHP

PHP: Gmail with RoundCube

Some times I have problem accessing Gmail because of some Firewall restrictions. Or I would like to have my own WebMail client for my mail service hosted with Google Apps. I tried several setting and I found out that it is not that difficult just you have to know the right parameters.

Here are the parameters that worked for me:
In your main.inc.php try to modify these setting:

// IMAP settings
$rcmail_config['default_host'] = 'ssl://imap.gmail.com:993';
$rcmail_config['default_port'] = 993;
$rcmail_config['imap_auth_type'] = null;

$rcmail_config['username_domain'] = 'gmail.com';
$rcmail_config['mail_domain'] = 'gmail.com';

//SMTP settings
$rcmail_config['smtp_server'] = 'ssl://smtp.gmail.com';
$rcmail_config['smtp_port'] = 465;
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';

//MBox settings
$rcmail_config['drafts_mbox'] = '[Gmail]/Drafts';
$rcmail_config['junk_mbox'] = '[Gmail]/Spam';
$rcmail_config['sent_mbox'] = '';
$rcmail_config['trash_mbox'] = '';
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');

[ad] Empty ad slot (#1)!

If you want to try. I made this setting on my sub domain mygmail.kristou.com. It is a RoudCube with the above settings.

PHP: Write to ini file array containing array

public function write_ini_file($data, $path, $mode) { foreach ($data as $key => $item) { if (is_array($item)) { $content .= “\n\n”; } } } else { $content .= “$key = \”$item\”\n”;

Click to continue reading “PHP: Write to ini file array containing array”

PHP: Append content to file

$myFile = “testFile.txt”; $fh = fopen($myFile, ‘a’) or die(“can’t open file”); $stringData = “New Stuff 1\n”; fwrite($fh, $stringData); $stringData = “New Stuff 2\n”; fwrite($fh, $stringData); fclose($fh);

Click to continue reading “PHP: Append content to file”

PHP: String token for string split

$token = strtok($string,”,”); $token = strtok(“,”);

Click to continue reading “PHP: String token for string split”

PHP: Find string between 2 strings

While looking in the Internet for a good function to strip a string, I found this blog where this function is implemented. function get_string_between($string, $start, $end){ $string = ” “.$string; $len = strpos($string,$end,$ini) – $ini;

Click to continue reading “PHP: Find string between 2 strings”