Proper usage:
http://uk3.php.net/strpos

Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

So instead of in mimemail.module:

if (strpos(variable_get('smtp_library', ''), 'mimemail')
  && !function_exists('drupal_mail_wrapper')) {

it should be something like:

if (strpos(variable_get('smtp_library', ''), 'mimemail') !== FALSE
  && !function_exists('drupal_mail_wrapper')) {

Comments

kenorb’s picture

The same in mimemail.inc:

function _mimemail_file($url = NULL, $name = '', $type = '', $disposition = 'related') {
  static $files = array();
  static $filenames = array();

  if ($url) {
    $url = _mimemail_url($url, 'TRUE');

    // If the $url is absolute, we're done here.
    if (strpos($url, '://') || preg_match('!mailto:!', $url)) {
      return $url; 

and

  foreach (explode("\n", trim($hdr)) as $row) {
    $split = strpos( $row, ':' );
    $name = trim(substr($row, 0, $split));
    $val  = trim(substr($row, $split+1));
    $headers[$name] = $val;
  } 

and

function _mimemail_url($url, $embed_file = NULL) {
  global $base_url;
  $url = urldecode($url);

  // If the URL is absolute or a mailto, return it as-is.
  if (strpos($url, '://') || preg_match('!mailto:!', $url)) {
    $url = str_replace(' ', '%20', $url);
    return $url; 
kenorb’s picture

Title: Use proper operators in if statements with strpos() » wrong params for strpos()
Version: 6.x-1.0-alpha1 » 6.x-1.x-dev
Status: Needs review » Active

And the same in mimemail.admin.inc:

function mimemail_admin_settings() {

  // override the smtp_library value if mimemail is chosen to handle all mail
  // this will cause drupal_mail to call mimemail()
  if (variable_get('mimemail_alter', 0)) {
    if (!strpos(variable_get('smtp_library', ''), 'mimemail')) { 

and

function mimemail_admin_settings() {
...
  }
  else {
    if (strpos(variable_get('smtp_library', ''), 'mimemail')) {
      db_query("DELETE FROM {variable} WHERE name = 'smtp_library'"); 
sgabe’s picture

Title: wrong params for strpos() » Use proper operators in if statements with strpos()
Version: 6.x-1.x-dev » 6.x-1.0-alpha1
Status: Active » Needs review
StatusFileSize
new2.59 KB

The attached patch adds the missing === and !== operators in if statements with strpos().

Changing version since the patch applies to 6.x-1.0-alpha1, and that is the latest now.

sgabe’s picture

Title: wrong params for strpos() » Use proper operators in if statements with strpos()
Version: 6.x-1.x-dev » 6.x-1.0-alpha2
Status: Active » Needs review
StatusFileSize
new2.56 KB

I am attaching a new patch against 6.x-1.0-alpha2, since the one in #3 is completely wrong, because I overlooked the brackets in the statements.

sgabe’s picture

Version: 6.x-1.0-alpha2 » 7.x-1.x-dev
StatusFileSize
new2.68 KB
+++ includes/mimemail.admin.inc	6 Apr 2010 20:07:19 -0000
@@ -16,12 +16,12 @@
+    if (!strpos(variable_get('smtp_library', ''), 'mimemail') === FALSE) {

It seems this line is wrong because of the NOT operator before strpos().

Attaching a rerolled patch against current HEAD.

sgabe’s picture

Status: Needs review » Fixed

Committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.