source: trunk/common/email.php @ 945

Revision 945, 1.3 KB checked in by btataroiu@…, 3 years ago (diff)

Merge changes from live

  • Property svn:eol-style set to native
Line 
1<?php
2
3// email routines
4
5// Word-wrap to avoid some problems with bad email clients
6define("IA_EMAIL_WORDRAP", 72);
7
8// if SMTP is enabled, feed some settings to PHP
9if (IA_SMTP_ENABLED) {
10    ini_set("SMTP", IA_SMTP_HOST);
11    ini_set("smtp_port", IA_SMTP_PORT);
12}
13
14// Sends text/plain email message. This wraps standard PHP email functions.
15// Default From: is IA_MAIL_SENDER_NO_REPLY
16function send_email($to, $subject, $plain_text_message, $from = null,
17                    $reply_to = null, $do_log = false)
18{
19    if (is_null($from)) {
20        $from = IA_MAIL_SENDER_NO_REPLY;
21    }
22
23    // if we don't specify reply-to, should be the same as the from
24    if (is_null($reply_to)) {
25        $reply_to = $from;
26    }
27
28    // put infoarena tag in mail subject
29    $subject = 'infoarena: '.$subject;
30
31    // word-wrap message, some mail-clients are stupid
32    $message = wordwrap($plain_text_message, IA_EMAIL_WORDRAP);
33
34    // headers
35    $headers = 'From: ' . $from . "\n" .
36               'Reply-To: ' . $reply_to . "\n" .
37               "Content-type: text/plain\n" .
38               'X-Mailer: infoarena/newsletter';
39
40    // log
41    if ($do_log) {
42        log_print("Sending mail to: {$to}, subject: {$subject}, "
43                  ."message length: ".strlen($message));
44    }
45
46    // send e-mail
47    return mail($to, $subject, $message, $headers);
48}
49
50?>
Note: See TracBrowser for help on using the repository browser.