PHP/Email/mail function

Материал из Web эксперт
Версия от 07:04, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Mail cc and bcc

<?php
   $headers = "From:sender@wbex.ru\r\n";
   $recipients = "b@java.ru,a@java.ru";
   mail($recipients, "This is the subject","This is the mail body", $headers);
?>



Mail to multiple recipients

<?php
   $headers = "From:sender@wbex.ru\r\n";
   $recipients = "test@java.ru,a@wbex.ru";
   mail($recipients, "This is the subject","This is the mail body", $headers);
?>



Multiple recipients all go into the address field, with commas separating them

<?php
$mailsend = mail("receiver@receipthost, a@hotmail.ru, a@aol.ru", "A Sample Subject Line", "Body of e-mail.");
print("$mailsend");
?>



Use the mail function

<?php
mail("receiver@receipthost.ru", "A Sample Subject Line", "Body of e-mail\r\nwith lines separated by the newline character.");
?>



Use variables in mail function

<?php
$address = "a@b.ru";
$Subject = "All I want for Christmas";
$body = "Joe";
$mailsend = mail("$address", "$Subject", "$body.");
print("$mailsend");
?>