|
Revision 11, 0.6 kB
(checked in by bobe, 3 years ago)
|
Envoi d’une alerte plutôt qu’une exception
|
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function mail($recipients, $subject, $message, $headers) |
|---|
| 4 |
{ |
|---|
| 5 |
$pattern = '(.*<)?([-!#$%&\'*+\\/0-9=?a-z^_`{|}~.]+)@[-a-z0-9.]+(?(1)>)(?:\\r\\n|$)'; |
|---|
| 6 |
|
|---|
| 7 |
if( !preg_match("/From: $pattern/Ui", $headers, $match) ) { |
|---|
| 8 |
trigger_error("mail() (online): Custom \"From:\" header needed", E_USER_WARNING); |
|---|
| 9 |
return false; |
|---|
| 10 |
} |
|---|
| 11 |
|
|---|
| 12 |
$from = $reply = $match[2]; |
|---|
| 13 |
$headers = str_replace($match[0], '', $headers); |
|---|
| 14 |
|
|---|
| 15 |
if( preg_match("/Reply-To: $pattern/Ui", $headers, $match) ) { |
|---|
| 16 |
$reply = $match[2]; |
|---|
| 17 |
$headers = str_replace($match[0], '', $headers); |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
return email($from, $recipients, $subject, $message, $reply, $headers); |
|---|
| 21 |
} |
|---|
| 22 |
|
|---|
| 23 |
?> |
|---|
| 24 |
|
|---|