Jump to content
xisto Community
kvarnerexpress

Sending Attachments Using Email Function In Php

Recommended Posts

I'm trying to send an attachment using the mail Php function.

It gets caught by the email server with an error. It seems to have a problem with the separator or who knows what. The server says something like "invalid separator on mime type."

The code is:

Code:

 // subject 	$subject  = "Hello There "; 	$mime_boundary = "<<<--==-->>>";         // headers         $headers  = "From: " . 'Tom' . " <" . 'texample@aol.com' . ">\r\n"; 	$headers .= "Return-Path: " . 'texample@aol.com' . "\r\n"; 	$headers .= "Reply-To: " . 'texample@aol.com' . "\r\n"; 	$headers .= "Content-type: Multipart/Mixed;\r\n"; 	$headers .= "Mime-Version: 1.0\r\n"; 	$headers .= "X-Mailer: PHP Mailer\r\n"; 	$headers .= " boundary=\"".$mime_boundary."\""; 	// message 	$message .= "This is a multi-part message in MIME format.\r\n";	$message .= "\r\n";	$message .= $mime_boundary."\r\n"; 	$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";	$message .= "Content-Transfer-Encoding: 7bit\r\n";	$message .= "\r\n";	$message  = "Attached is the file "; 	$message .= "."; 	$message .= "\n\n"; 	$message .= $mime_boundary."\r\n"; 		$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";	$message .= " name=\"feedback.txt\"\r\n";	$message .= "Content-Description: Requested File;\r\n";	$message .= " filename=\"feedback.txt\"\r\n";	$message .= "\r\n";	$message .= $mime_boundary."\r\n";         $email = "dianne@aol.com"; 	// Send 	if (mail ($email, $subject, $message, $headers)) {     echo "<script>alert ('Your email was sent. ')</script>";     }	else {      echo "<script>alert ('Unable to send your email.')</script>"; 	}  



I'm not trying to use the MimeMail class or anything since
the version of Php that we're using is not supported by it.
I'm just trying to do this using the mail function.

The code seems o.k. when compared to others that I have
seen. Can't figure out what's going on.

Thanks in advance for reading this and any suggestion or
solutions.
kvarnerexpress

Share this post


Link to post
Share on other sites

asking a very stupid question but does the sever actually allow you to use mail functions, cause this one doesn't. I mean i have tons of scripts that i've used that work like a charm but you should look to php.net and see if there's anything there that will answer you question or fix your problem.round

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.