IP Address=38.107.179.236

I moved the notes on MIME and multipart attachment to here at the bottom of the page.
This is the source code for this program.
You can go back to where you came from by clicking here

dump headers dump length After Before Don't     use base64 not imap
From:
To:
CC:
BCC:
Reply To:
Date :)
Subject:
  Send as TEXT , HTML    Put debug info in E-mail
  Attach BEFORE screws up HTML 1                        \n before file
Attach file after HTML in header data section 1         \n after file   
Attach file to end of body as opposed to the headers 1
 
File Name as Attachment
vs INLINE
name
for INLINE

Debug Window

PHP.INI stuff

These are the values I want:
SMTP "localhost" PHP_INI_ALL
smtp_port "25" PHP_INI_ALL
sendmail_from NULL PHP_INI_ALL
sendmail_path "/usr/sbin/sendmail -t -i" PHP_INI_SYSTEM
And these are the actual values that PHP returns
smtp_portini_get('smtp_port')
SMTPini_get('SMTP')
sendmail_fromini_get('sendmail_from')
sendmail_pathini_get('sendmail_path')
Lets try to reset one of them using this code
$ini_value=ini_set('sendmail_from','root@unix.com');
and see what happens! Here are the results and it looks like the change worked!
smtp_portini_get('smtp_port')
SMTPini_get('SMTP')
sendmail_fromini_get('sendmail_from')
sendmail_pathini_get('sendmail_path')

Dump Headers

When you check the "dump headers" box I write a whole bunch of debug information to the right of the form in a box with a yellow background.

You will see all the header and data information I am passing to the program that sends the e-mail.

dump length

When you click on the dump length button for each file uploaded I will generate a header record that has the length of the uploaded file in bytes. That is the length of the file after it has been converted to mime. That header record looks like this
Content-Length: 9672
And I am not sure how the software uses this. At this point in time I am trying to avoid writting the code using "multi-part forms" because that gets a little messy and I am hoping by allowing the length I won't need to use "multi-part forms"

When I first heard the term "multi-part forms" I thought the data was cut into chunks and sent as multi-parts. Well that may or may not be true but it has absolutely nothing to do with "multi-part forms".

A "multi-part form" is when you send several files in one data stream and use unique string ID to delimit the files.

And example is send three files using the string id

frozen_frogs_drink_beer_and_smoke_cigarettes
Would look like this:
--frozen_frogs_drink_beer_and_smoke_cigarettes
Data for file #1
--frozen_frogs_drink_beer_and_smoke_cigarettes
Data for file #2
--frozen_frogs_drink_beer_and_smoke_cigarettes
Data for file #3
--frozen_frogs_drink_beer_and_smoke_cigarettes
Only it seems that it is a little bit more complex then that!

use base64 not imap

The orginal code I wrote uses a function
imap_binary()
to convert the data from text to base64 or mime format. Some versions of PHP don't have that functions so the orginal program blows up when loaded on those systems.

To get around that problem I check to see if the function imap_binary() exists and if it doesn't I use this code

$base64data0=base64_encode($file_data);
$base64data=chunk_split($base64data0,60);
to convert the data to mime or base64 format, then I split the data into 60 byte blocks.

So that I can test this code on a system that has imap_binary() I put this check box so I can force it to use the above code instead of imap_binary().

Date:

You can use this field to set the date the email was sent. If you leave it blank I use the default time, whatever that is. You can put anything you want in it like:
Yesterday
Tomorrow
December 25, 2029
July 4, 1776
The first time the program is run I will put the current Phoenix time in the field with something like this
Mon, 24 Dec 2007 11:37:20 -0900 (MST)
In this case
Mon - is the day of the week or Monday
24 - is the day of the month or Dec 24
Dec - is the month or December
2007 - is the year
11:37:20 - is the current time
-0900 (MST) - says that Phoenix time is 9 hours before London time
(MST) - says that Phoenix time is Mountain Standard Time

Put debug info in E-mail

OK it is Christmas time and all the cartoonists are making fun of the homeland security thugs and how they are going to shake down Santa Claus.

So for fun I sent a couple of cartoonists e-mails telling them how they are in trouble with the TSA thugs for thinking they have First Amendment rights.

This switch tells the software not to put any of the debug information into the body of the mail, so the e-mail will look like a message from the government thugs in the homeland security department.

And just so the homeland security thugs won't jail me for life, I used the non-existant Department of Homeland IN-Security as the e-mail address

Notes on Before and After1

No files attached

When you DON'T attach a file and send HTML it seems to always work irregardless of if you click on the before or after buttons.

One or more files attached

When one or more files are attached and you send HTML it always works with the after button checked.

When one or more files are attached and you send HTML the HTML is always screwed up when the before button checked.

Attach file to end of body

When the button that says
Attach file to end of body
was clicked on and you attached files and sent HTML it always seemed to screw stuff up.

That is why i disabled the button.

Attaching files still doesn't work

I still have to figure out how to attach files so they are NOT in the body of the text, but are attached as a file which you can click on and down load.

I think that must be done using a multi-part form header. But I still have to play with it.

The way the current code works is I just send the file off using something like this

filename="resume.doc"
Content-type: application/msword
Content-transfer-encoding: base64
Content-Length: 90298
0 or more blank lines
0M8R4KGxGu mime or base64 data AAAAAAAAAAAPgADAP7
0 or more blank lines

\n Before File

This is the number of blank lines to print before dumping the file. It is just for debugging. I think I can get by with out any blanks lines. But there is a remote chance that one blank line may be needed.

\n After File

This is the number of blank lines to print after dumping the file. It is just for debugging. I think I can get by with out any blanks lines. But there is a remote chance that one blank line may be needed.

As Attachment

I beleive there are two types of attachments you can have when you send a file with an e-mail.

The first one is an attachment that the user can download to his computer.

That is what you get when you click on one of these buttons. When you do this i generate the header record

Content-Disposition: attachment;
The 2nd type of attachment is for use when you have the email displayed as HTML.

You could have an image attached to display in the HTML, or another HTML web page for them to jump to when they click on an A tag. And this type of attachment is used for that.

Inline Name

In this case the NAME field is used to identify the name of the image or other html to jump to.

In this case I add the name to the following header record

Content-type: image/pjpeg name="frogs"
In the above case I suspect that the name "frogs" would be used in either an
<img src="frogs">
tag or if the attached thing was html it would be used in an A tag like this
<a href="frogs">   </a>

Uploaded file name

For each file you upload I generate a header record that looks like this with the name of the uploaded file. The name is the filename of the file on the computer which it was uploaded from
filename="222.jpg"
I am not sure if this file name can be used in the html tags. Nor am I sure of what this file name can be used for anywhere.

Uploaded file name on the remote server

When the file gets to the server it is usually saved in
/tmp/xxx
where xxx is a randomly generated file name

TEXT HTML Radio buttons

If you click on the HTML radio button in the two button radio set which is TEXT and HTML I will generate this header records which says to send the e-mail as HTML
Content-type: text/html
I am not sure how the mail function uses it.
 

MIME notes