User login

Sending pictures by e-mail to a Drupal site

Dan successfully did this with the mailhandler and mailsave modules.

He'll have to post how. Here's some utterly irrelevant and useless background:

Images with mailhandler... back in 2003!
http://drupal.org/node/2702

I successfully implemented imagehandler.module for Drupal 4.0. Since mailhandler and image module has changed a lot since, you probably need retune the function. It currently supports only JPG.

function imagehandler_mailhandler($node, $stream, $msg_number, $mailbox) {
  $image = mailhandler_get_part($stream, $msg_number, "IMAGE/JPEG");
  if ($image) {
    $node->type = "image";
    $node->format = "jpg";
    $node->body = mailhandler_get_part($stream, $msg_number, "TEXT/PLAIN");
    $node->image_id = md5(rand());
    $node->image_name =  $node->title.".jpg";
    $node->thumb_name = _image_thumbname($node);

    $dest = fopen(_image_tempname($node),"w");                                     
    fputs($dest,$image,strlen($image));                                                                     
    fclose($dest);

    watchdog("message", "Retreived image $node->image_name from incoming mail");

  }
  return $node; 
}

Also old, but not as old:
mailsave module for drupal
http://www.stuartandnicola.com/node/433

mailhandler images names

Dan successfully did this with the mailhandler and mailsave modules.

He'll have to post how. Here's some utterly irrelevant and useless background:

Images with mailhandler... back in 2003!
http://drupal.org/node/2702

I successfully implemented imagehandler.module for Drupal 4.0. Since mailhandler and image module has changed a lot since, you probably need retune the function. It currently supports only JPG.

function imagehandler_mailhandler($node, $stream, $msg_number, $mailbox) {
  $image = mailhandler_get_part($stream, $msg_number, "IMAGE/JPEG");
  if ($image) {
    $node->type = "image";
    $node->format = "jpg";
    $node->body = mailhandler_get_part($stream, $msg_number, "TEXT/PLAIN");
    $node->image_id = md5(rand());
    $node->image_name =  $node->title.".jpg";
    $node->thumb_name = _image_thumbname($node);

    $dest = fopen(_image_tempname($node),"w");                                     
    fputs($dest,$image,strlen($image));                                                                     
    fclose($dest);

    watchdog("message", "Retreived image $node->image_name from incoming mail");

  }
  return $node; 
}

Also old, but not as old:
mailsave module for drupal
http://www.stuartandnicola.com/node/433

mailhandler images names

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.