Changeset 2106 for trunk


Ignore:
Timestamp:
Sep 25, 2007, 11:52:00 PM (17 years ago)
Author:
rub
Message:

Resolved 0000580: Send mail by define smtp configuration

Merge branch-1_7 2104:2105 into BSF

Location:
trunk/include
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/config_default.inc.php

    r2104 r2106  
    285285//  Value could be text/plain  or text/html
    286286$conf['default_email_format'] = 'text/html';
     287
     288// smtp configuration
     289// (work if fsockopen function is allowed for smtp port)
     290// smtp_host: smtp server host
     291//  if null, regular mail function is used
     292//   format: hoststring[:port]
     293//   exemple: smtp.pwg.net:21
     294// smtp_user/smtp_password: user & password for smtp identication
     295$conf['smtp_host'] = '';
     296$conf['smtp_user'] = '';
     297$conf['smtp_password'] = '';
     298
    287299
    288300// check_upgrade_feed: check if there are database upgrade required. Set to
  • trunk/include/functions_mail.inc.php

    r2059 r2106  
    4747    'mail_options' => $conf['mail_options'],
    4848    'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
    49     'default_email_format' => $conf['default_email_format']
     49    'default_email_format' => $conf['default_email_format'],
     50    'use_smtp' => !empty($conf['smtp_host']),
     51    'smtp_host' => $conf['smtp_host'],
     52    'smtp_user' => $conf['smtp_user'],
     53    'smtp_password' => $conf['smtp_password']
    5054    );
    5155
     
    7478  if ($conf['enabled_format_email'])
    7579  {
    76     $cvt7b_name = '"'.addslashes(str_translate_to_ascii7bits($name)).'"';
    77 
    78     if (strpos($email, '<') === false)
    79     {
    80       return $cvt7b_name.' <'.$email.'>';
     80    // Spring cleaning
     81    $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name));
     82    $cvt_email = trim(preg_replace('#[\n\r]+#s', '', $email));
     83    // Ascii convertion
     84    $cvt_name = '"'.addslashes(str_translate_to_ascii7bits($cvt_name)).'"';
     85
     86    if (strpos($cvt_email, '<') === false)
     87    {
     88      return $cvt_name.' <'.$cvt_email.'>';
    8189    }
    8290    else
    8391    {
    84       return $cvt7b_name.$email;
     92      return $cvt_name.$cvt_email;
    8593    }
    8694  }
    8795  else
    8896  {
    89     return $email;
     97    return $cvt_email;
    9098  }
    9199}
     
    437445}
    438446
    439 
    440447/*
    441448 * sends an email, using PhpWebGallery specific informations
     
    499506    $args['subject'] = 'PhpWebGallery';
    500507  }
    501   $cvt7b_subject = str_translate_to_ascii7bits($args['subject']);
     508  // Spring cleaning
     509  $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject']));
     510  // Ascii convertion
     511  $cvt_subject = str_translate_to_ascii7bits($cvt_subject);
    502512
    503513  if (!isset($args['content']))
     
    545555  $headers.= '  reply-type=original'."\n";
    546556  $headers.= 'MIME-Version: 1.0'."\n";
     557  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
    547558
    548559  $content = '';
     
    674685  }*/
    675686
    676   if ($conf_mail['mail_options'])
    677   {
    678     $options = '-f '.$conf_mail['email_webmaster'];
    679    
    680     return mail($to, $cvt7b_subject, $content, $headers, $options);
     687  if ($conf_mail['use_smtp'])
     688  {
     689    include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' );
     690    $smtp_mail = new smtp_mail(
     691      $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'],
     692      $conf_mail['email_webmaster']);
     693    return $smtp_mail->mail($to, $cvt_subject, $content, $headers);
    681694  }
    682695  else
    683696  {
    684     return mail($to, $cvt7b_subject, $content, $headers);
     697    if ($conf_mail['mail_options'])
     698    {
     699      $options = '-f '.$conf_mail['email_webmaster'];
     700      return mail($to, $cvt_subject, $content, $headers, $options);
     701    }
     702    else
     703    {
     704      return mail($to, $cvt_subject, $content, $headers);
     705    }
    685706  }
    686707}
Note: See TracChangeset for help on using the changeset viewer.