Page 1 of 1

unable to finish tutorial

Posted: Wed Jul 18, 2012 7:53 pm
by ud3webdev
Hey, the first 2 parts were okay, and then after about 1:40 min in to the 3rd video the video quality just went to crap for some reason, it was on 720p, then i tested all quality levels and its just a mess.http://www.youtube.com/watch?v=3tnFPs_M ... B56BE54CEB

not sure if some one has the source code for this mail attachment video but this is how far im able to get and im sure even this is wrong because i cant make it out.
function mail_file($to, $from, $subject, $body, $file) {
	$boundary = md5(rand());
	
	$headers = array(
		'MIME-Version: 1.0',
		"from: ($from)",
		"Content=Type: multipart/mixed; boundry= ($boundry)"
	};
	
	$message = array(
		
	);
}
thanks.

Re: unable to finish tutorial

Posted: Fri Jul 20, 2012 1:56 am
by jacek
Hmm, not sure what happened there. I guess I have a video to re-make :P

Here is the code anyway
<?php

// sends the given meesage to the given email address attaching the given file.
function mail_file($to, $from, $subject, $body, $file){
	$boundary = md5(rand());
	
	$headers = array(
		'MIME-Version: 1.0',
		"From: {$from}",
		"Content-Type: multipart/mixed; boundary=\"{$boundary}\""
	);
	
	$message = array(
		"--{$boundary}",
		"Content-Type: text/plain; charset=\"utf-8\"",
		"Content-Transfer-Encoding: 7bit",
		"",
		chunk_split($body),
		"--{$boundary}",
		"Content-Type: {$file['type']}; name=\"{$file['name']}\"",
		"Content-Disposition: attachment; filename=\"{$file['name']}\"",
		"Content-Transfer-Encoding: base64",
		"",
		chunk_split(base64_encode(file_get_contents($file['path']))),
		"--{$boundary}--",
	);
	
	return mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers));
}

?>