Your life would be a whole load easier if you were using the PHPMailer class:
http://phpmailer.worxware.
f
http://phpmailer.worxware.
Main Topics
Browse All TopicsThe code below works fine on my local pc (localhost) - which is Windows XP SP3 with IIS.
When I move it to my hosted site, which is UNIX/Apache, it doesn't work. The email is received, but there is no attachment, and the text of the email shows all of the boundaries and the code for the file. See my next post for what it looks like.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Your life would be a whole load easier if you were using the PHPMailer class:
http://phpmailer.worxware.
f
http://phpmailer.worxware.
you get the class by clicking the download link on the left of the example page; or simpler, go here:
http://sourceforge.ne
the
http://sourceforge.
is the latest version for PHP 5 / 6
you might also want to look at this:
http://phpmailer.worx
a
http://phpmailer.worxware.
for a full tutorial.
HTH
the -> syntax shows that you are calling a function (method) or accessing a variable (property) in the class.
there's plenty of info on these basics in the PHP manual pages, such as here:
http://us.php.net/man
I did get this to work using just php mail's function. Code is posted below. It works on localhost and also my hosting account, and both Eudora 7 and Outlook receive the mail properly.
The critical differences between it and what I originally posted are:
1. Fixed how $body was defined. The code I copied first defined $body as "Here is the file \n\n", then added the "This is a multipart message ... \n\n" stuff, then the content type and content encoding, then tacked on the original "Here is the file..." stuff. Now, I first set $body with the content type and encoding, then the "Here is the file". I'm not sure why it was done the way it was in the first place. Kind of convoluted.
2. Used the constant PHP_EOL for all end-of-lines instead of "\n"
3. Redid the string syntax so I only used single-quote strings (easier for me to see what's going on)
4. Removed an extra new line just before the MIME declaration - this was a critical step. With the extra newline, it worked on localhost, but not my remote host. With it gone, it worked on both.
Business Accounts
Answer for Membership
by: alicia1234Posted on 2009-07-10 at 19:28:35ID: 24828809
Here's what the email looks like when sent through the remote host.
I tried changing some of the "\n" to "\r\n" but I honestly do not understand what I'm doing so I'm just grasping at straws.
Select allOpen in new window