|
(PHP 3, PHP 4 >= 4.0.0) mail -- send mail Popisbool mail ( string to, string subject, string message [, string additional_headers])
mail() automaticky odmailuje vzkaz specifikovan² v
message p°φjemci specifikovanΘmu v
to. P°idßnφm Φßrky mezi adresami v
to m∙╛ete specifikovat vφce p°φjemc∙.
P°φklad 1. Odeslßnφ mailu. mail("rasmus@lerdorf.on.ca", "M∙j p°edm∞t", "╪ßdek 1\n╪ßdek 2\n╪ßdek 3"); |
|
Pokud je p°edßn Φtvrt² argument, jeho hodnota se vlo╛φ na konec hlaviΦek.
Toto se obvykle pou╛φvß k p°idßnφ extra hlaviΦek.
VφcenßsobnΘ hlaviΦky se odd∞lujφ za°ßdkovßnφm.
P°φklad 2. Odeslßnφ mailu s extra hlaviΦkami. mail("nobody@aol.com", "p°edm∞t", $message,
"From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion()); |
|
K vytvo°enφ komplexnφch email∙ m∙╛ete takΘ pou╛φt pom∞rn∞ jednoduchΘ techniky
pro tvorbu °et∞zc∙.
P°φklad 3. Odeslßnφ komplexnφho emailu /* recipients */
$recipient .= "Mary <mary@u.college.edu>" . ", " ; //v╣imn∞te si Φßrky
$recipient .= "Kelly <kelly@u.college.edu> . ", ";
$recipient .= "ronabop@php.net";
/* subject */
$subject = "Birthday Reminders for August";
/* message */
$message .= "Nßsledujφcφ email obsahuje formßtovanou ASCII tabulku\n";
$message .= "Day \t\tMonth \t\tYear\n";
$message .= "3rd \t\tAug \t\t1970\n";
$message .= "17rd\t\tAug \t\t1973\n";
/* m∙╛ete p°idat signaturu */
$message .= "--\r\n"; //odd∞lovaΦ signatury
$message .= "Birthday reminder copylefted by public domain";
/* dodateΦnΘ hlaviΦky pro chyby, From, cc, bcc, atd */
$headers .= "From: Birthday Reminder <birthday@php.net>\n";
$headers .= "X-Sender: <birthday@php.net>\n";
$headers .= "X-Mailer: PHP\n"; // mailov² klient
$headers .= "X-Priority: 1\n"; // Urgentnφ vzkaz!
$headers .= "Return-Path: <birthday@php.net>\n"; // Nßvratovß cesta pro chyby
/* Pokud chcete poslat HTML email, odkomentujte nßsledujφcφ °ßdek */
// $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime typ
$headers .= "cc:birthdayarchive@php.net\n"; // CC
$headers .= "bcc:birthdaycheck@php.net, birthdaygifts@php.net\n"; // BCC
/* a te∩ to ode╣leme */
mail($recipient, $subject, $message, $headers); |
|
| |