/[drupal]/contributions/tricks/smtp/smtp.inc
ViewVC logotype

Contents of /contributions/tricks/smtp/smtp.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Thu Dec 11 13:59:58 2003 UTC (5 years, 11 months ago) by mathias
Branch: MAIN
CVS Tags: HEAD
Branch point for: drop
Changes since 1.5: +3 -3 lines
File MIME type: text/x-php
Single-quoted strings do not expand newlines (\n) in PHP.  As such, the headers array was not being filled.
1 <?php
2 // $Id: smtp.inc,v 1.5 2003/11/17 15:36:57 kjartan Exp $
3 include_once 'includes/class.smtp.inc';
4
5 function user_mail_wrapper($mail, $subject, $message, $header) {
6 // The smtp server host/ip
7 $params['host'] = ini_get('SMTP');
8 // The smtp server port
9 $params['port'] = 25;
10 // What to use when sending the helo command. Typically, your domain/hostname
11 $params['helo'] = $_SERVER['HTTP_HOST'];
12 // Whether to use basic authentication or not
13 $params['auth'] = FALSE;
14 // Username for authentication
15 //$params['user'] = 'testuser';
16 // Password for authentication
17 //$params['pass'] = 'testuser';
18
19 // The recipients (can be multiple)
20 $send_params['recipients'] = $mail;
21 // The headers of the mail
22 $send_params['headers'] = explode("\n", $header ."\nSubject: $subject\nTo: $mail");
23 // The body of the email
24 $send_params['body'] = str_replace("\n", "\r\n", $message);
25
26 $smtp = smtp::connect($params);
27 if (count($smtp->errors)) {
28 watchdog('error', 'mail connect error: '. implode('<br />', $smtp->errors));
29 return false;
30 }
31 $smtp->send($send_params);
32 if (count($smtp->errors)) {
33 watchdog('error', 'mail send error: '. implode('<br />', $smtp->errors));
34 return false;
35 }
36
37 return true;
38 }
39 ?>

  ViewVC Help
Powered by ViewVC 1.1.2