Uncategorized

How to set up your own Postfix server on Debian

I have many problems with sending an emails from my hosting provider.
Sometimes email just get to the spam folder and user never gets it. If it was an important email it is a big problem.

I have purchased a VPS with my own dedicated IP address just to create a SMTP server.
My server is on Debian 5.0 and I have chosen Postfix as my mail server.
Installation is as easy as “apt-get install postfix”.

Everything worked as expected (I have followed few online tutorials) and I got my server up and running with small exception – I WASN’T ABLE TO SEND EMAILS :)

I kept getting errors:

Sep  3 02:55:49 debian postfix/qmgr[22990]: 68BB22B125: from=<sender@mail.myserver.com>, size=621, nrcpt=1 (queue active)
Sep  3 02:56:19 debian postfix/smtp[23055]: connect to gmail.com[xxx.xxx.xxx.xxx]:25: Connection timed out
Sep  3 02:56:19 debian postfix/smtp[23055]: 68BB22B125: to=<user@gmail.com>, relay=none, delay=1010, delays=980/0.02/30/0, dsn=4.4.1, status=deferred (connect to gmail.com[xxx.xxx.xxx.xxx]:25: Connection timed out)

It took me few hours of research and dozen of different configuration tests etc but solution was as easy as setting:

disable_dns_lookups = no

in /etc/postfix/main.cf

hope it help someone and saves you a lot of time


Jak przekonwertowa? baz? danych z ogonkami na UTF8

Podczas tworzenia jednego z moich serwisów (www.rabatek.pl) pope?ni?em bardzo du?y b??d: zaraz po ustanowieniu po??czenia do bazy nie zmieni?em kodowania na UTF8 (domy?lnie bylo latin1). Wszystko przez to ?e po raz pierwszy postanowi?em skorzysta? z klasy PEAR::MDB2 i mi to umkn??o.

W ka?dym b?d? razie strona ju? sobie istnieje kilka miesi?cy i wszystko super dzia?a – do czasu. W wersji beta przerobi?em wyszukiwark? i okaza?o si?, ?e jak wpisz? np. “Wroc?aw” to nic nie znajduje – wszystko przez te piekielne ogonki. Baza ma ju? w tej chwili kilka tysi?cy rekordów wi?c r?czne poprawianie odpada ca?kowicie.

Z pomoc? przyszed? bardzo prosty skrypt PHP. Napisa?em go w 15 minut i nie ma w nim kontroli b??dów, komentarzy itp – po prostu wykonuje swoj? robot? i tyle.

Postanowi?em si? tym skryptem z wami podzieli? gdy? wiem ?e nie tylko ja mam problem z ogonkami.

Uwagi i komentarze mile widziane

define('DB_HOST',              'twoje_ip');
define('DB_USER',               'user_do_bazy');
define('DB_PASS',               'haslo_do_bazy');
define('DB_NAME',               'nazwa_bazy');
 
define('DB_CHARSET',            'UTF8');
define('DB_NAMES',               'UTF8');
define('DB_COLLATION',         'utf8_general_ci');
 
function chars_translate($string) {
 
    $org_letters = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż');
    $utf8_letters = array('?','?','?','?','?','ó','?','?','?','?','?','?','?','?','Ó','?','?','?');;
    $string = str_replace($org_letters, $utf8_letters, $string);
    return $string;
}
 
$link = @mysql_connect(DB_HOST, DB_USER, DB_PASS);
if (!$link) {
    echo "error connection to the database: ".mysql_error();
}
 
if (!mysql_select_db(DB_NAME, $link)) {
    echo "error selecting a database: ".mysql_error();
}
 
$tables = array();
 
// odczytaj wszystkie tabele
$query = "SHOW TABLE STATUS ";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
    if ($row['Comment'] != 'VIEW') {
        $tables[] = $row['Name'];
    }
}
 
// pobierz dane ze starych tabeli
$records = array();
foreach ($tables as $table) {
    $query = "SELECT * FROM ".$table;
    $result = mysql_query($query);
    $records[$table] = array();
    $i = 0;
    while($row = mysql_fetch_assoc($result)) {
        foreach ($row as $key =&gt; $value) {
            $records[$table][$i][$key] = chars_translate($value);
        }
        $i++;
    }
}
 
// ustaw poprawne kodowanie
mysql_query("SET CHARACTER SET ".DB_CHARSET);
mysql_query("SET NAMES ".DB_NAMES);
mysql_query("SET collation_connection = ".DB_COLLATION);
 
// stworz nowe tabele i wypelnij je danymi
foreach ($tables as $table) {
    $query = "CREATE TABLE ".$table."_new LIKE ".$table;
    $result = mysql_query($query);
 
    if (empty($records[$table])) {
        continue;
    }
    $columns = implode(",", array_keys($records[$table][0]));
    $query = "INSERT INTO ".$table."_new (".$columns.") VALUES ";
 
    foreach ($records[$table] as $row) {
        $query .= "('".implode("','", $row)."'),";
    }
 
    $query = substr($query, 0, -1);
    $result = mysql_query($query);
 
    // skasuj stara tabele
    $query = "DROP TABLE ".$table;
    $result = mysql_query($query);
 
    // zmien nazwe tabeli
    $query = "RENAME TABLE ".$table."_new TO ".$table;
    $result = mysql_query($query);
 
    echo "gotowy ".$table."\n";
    flush();
}
 
echo "KONIEC\n";
1 Comment more...

“Cytrynowka” Polish Lemon Vodka

I was supposed to write about web development but recently I found my old recipe on how to make your own ‘cytrynowka’. All you need is:

  • 1L 190 proof alcohol (I use EVERCLEAR 190 PROOF GRAIN ALCOHOL)
  • 8-10 lemons (depends on size)
  • 1.5 glass of sugar
  • little bit of salt
  • 1L of water

- Ok so to start you have to wash lemons and cut off the ends (and throw them away). Cut all lemons into the pieces (about 1/4 – 1/2 inch in size).

- Put lemon pieces into the metal bowl or pot, add sugar, salt and one glass of water. Add Everclear. Squeeze the lemons very well and leave like that for about 2 hours (don’t forget because it will become bitter if you keep it to long)

- soak and remove lemon pieces, filter everything (use gauze pads to filter out even the smallest pieces of lemon). Add 3 glasses of water

- in about 2-3 days filter everything again

- 5 days later it is ready to drink :) best served chilled in shot glasses :)

enjoy


Copyright © 1996-2010 Artur's Blog. All rights reserved.
iDream theme by Templates Next | Powered by WordPress