Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8912489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:12:47+00:00 2026-06-15T04:12:47+00:00

I have a .forward.postix that is piping incoming emails to a shell account, and

  • 0

I have a .forward.postix that is piping incoming emails to a shell account, and consequently to a PHP script that parses the emails – awesome.

As of now, and based on everything I’ve seen online, I’m using the explode('From: ', $email); approach to split everything down into the vars I need for my database.

Enter attachments! Using the same approach, I’m doing this to pull out a jpg attachment – but it appears not every email client formats the raw source the same way and it’s causing some headaches!

$contentType1 = explode('Content-type: image/jpg;', $email); //start ContentType
$contentType2 = explode("--Boundary_", $contentType1[1]); //end ContentType

$jpg1 = explode("\n\n", $contentType2[0]); //double return starts base64 blob
$jpg2 = explode("\n\n", $jpg1[1]); //double return marks end of base64 blob

$image = base64_decode($jpg2[0]); //decode base64 blob into jpg raw

Here’s my issue:
Not all mail clients – like GMail for example – list an attachment as 'Content-type: image/jpg'. GMail puts in 'Content-Type: IMAGE/JPEG' and sometimes sends it as 'Content-Type: image/jpeg'! Which don’t match my explode…

My Question: Does someone know a better way of finding the bounds of a base64 blob? or maybe a case-insensitive way of exploding the 'Content-Type:' so I can then try against image/jpg or image-jpeg to see what matches?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:12:48+00:00Added an answer on June 15, 2026 at 4:12 am

    You can try to split your string using preg_split(). Maybe something like this

    $pattern = '#content-type: image/jpe?g#i';
    $split_array = preg_split($pattern, $email);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this regex that uses forward and backward look-aheads: import re re.compile(<!inc\((?=.*?\)!>)|(?<=<!inc\(.*?)\)!>) I'm
I have this error that is keeping me from moving forward. I basically have
I've noticed recently that I don't have to forward ports for mmorpg's that I
I have set up mail to an incoming address to forward in postfix to
I have a small SQL script that I'm executing with Oracle's SQL*Plus to emulate
With win32 threads I have the straight forward GetExitCodeThread() that gives me the value
I have one straight forward question. Suppose i have a projectA and now i
I'm looking forward to have an update on the following topic as it does
I am developing a Game in which sprite have to jump forward . I
I have a very straight forward master/slave replication setup with MySQL. ActiveRecord is configured

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.