Click here to Skip to main content
15,909,546 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: Beginner ask some questions ? Pin
User 17164925-Oct-10 3:23
professionalUser 17164925-Oct-10 3:23 
GeneralRe: Beginner ask some questions ? Pin
Honeyboy_205-Oct-10 4:42
Honeyboy_205-Oct-10 4:42 
GeneralRe: Beginner ask some questions ? Pin
User 17164925-Oct-10 5:05
professionalUser 17164925-Oct-10 5:05 
Questionlinux Pin
sheronici3-Oct-10 6:13
sheronici3-Oct-10 6:13 
AnswerRe: linux Pin
LloydA11111-Dec-10 10:13
LloydA11111-Dec-10 10:13 
AnswerRe: linux Pin
LloydA11120-Dec-10 6:46
LloydA11120-Dec-10 6:46 
AnswerRe: linux Pin
Iranian MM7-Sep-11 6:41
Iranian MM7-Sep-11 6:41 
QuestionSend attachment through email Pin
DinoRondelly22-Sep-10 7:50
DinoRondelly22-Sep-10 7:50 
I am having trouble attaching a wav file to email through PHP.

<code lang=php>	
                $to = "John.Doe@TryHarder.com";
		
		$from = "John.Doe@TryHarder.com";
		
		$subject = "Test Email";
		
		$message = "This is your test email";
		
		$fileatt = "[Removed]\E1002.wav";
		
		$fileatttype = "application/wav";
		
		$fileattname = "E1002.wav";
		
		$headers = "From: $from";
		
		
		//Open File
		$file = fopen( $fileatt, 'rb');
		
		$data = fread( $file, filesize( $fileatt ) );
		
		fclose( $file );
		
		
		//Add MIME content 
		$semi_rand = md5( time() );
		
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
		
		$headers .= "nMIME-Version: 1.0n". 
		
		"Content-Type: multipart/mixed;n" .
		
		" boundary= {$mime_boundary}";
		
		$message = "This is a multi-part message in MIME format.nn" .
		
		"–{$mime_boundary}n" .
		
		"Content-Type: text/plain; charset= iso-8859-1 n".
		
		"Content-Transfer-Encoding: 7bitnn" .

		$message . "nn";

		$data = chunk_split( base64_encode( $data ) );
		
		$message .= "–{$mime_boundary}n" .
		
		"Content-Type: {$fileatttype};n".
		
		" name= {$fileattname} n" .

		"Content-Disposition: attachment;n".
		
		" filename={$fileattname} n".
		
		"Content-Transfer-Encoding: base64nn" .
		
		$data . "nn" .
		
		"–{$mime_boundary}–n";
		
		//Send Email
		$mail_sent = mail($to,$subject,$message,$headers);
		
		//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
		echo $mail_sent ? "Mail sent" : "Mail failed";
</code>


It seems what ever MIME is doing ends up being the body of the email and the attachment doesn't come though.

If someone could point out what i am doing wrong i would be forever grateful.

I am fairly new to PHP so please forgive me if this comes of as basic.
AnswerRe: Send attachment through email Pin
DinoRondelly22-Sep-10 8:45
DinoRondelly22-Sep-10 8:45 
QuestionHow to execute a URL in cron job at Linux Server Pin
Varun Sareen21-Sep-10 18:52
Varun Sareen21-Sep-10 18:52 
AnswerRe: How to execute a URL in cron job at Linux Server Pin
cjoki22-Sep-10 4:51
cjoki22-Sep-10 4:51 
GeneralRe: How to execute a URL in cron job at Linux Server Pin
Varun Sareen22-Sep-10 21:14
Varun Sareen22-Sep-10 21:14 
GeneralRe: How to execute a URL in cron job at Linux Server Pin
cjoki23-Sep-10 5:58
cjoki23-Sep-10 5:58 
GeneralRe: How to execute a URL in cron job at Linux Server Pin
Varun Sareen23-Sep-10 7:25
Varun Sareen23-Sep-10 7:25 
GeneralRe: How to execute a URL in cron job at Linux Server Pin
cjoki23-Sep-10 11:58
cjoki23-Sep-10 11:58 
GeneralRe: How to execute a URL in cron job at Linux Server Pin
Varun Sareen23-Sep-10 18:47
Varun Sareen23-Sep-10 18:47 
GeneralRe: How to execute a URL in cron job at Linux Server Pin
markkuk24-Sep-10 0:07
markkuk24-Sep-10 0:07 
GeneralRe: How to execute a URL in cron job at Linux Server [modified] Pin
cjoki24-Sep-10 4:34
cjoki24-Sep-10 4:34 
GeneralHow to execute a URL in cron job at Linux Server Pin
Varun Sareen28-Sep-10 20:37
Varun Sareen28-Sep-10 20:37 
QuestionUTF-8 format with mail() Pin
grmihel220-Sep-10 4:30
grmihel220-Sep-10 4:30 
Questionhtml in database Pin
AndyInUK15-Sep-10 23:32
AndyInUK15-Sep-10 23:32 
AnswerRe: html in database Pin
Gerben Jongerius16-Sep-10 2:04
Gerben Jongerius16-Sep-10 2:04 
GeneralRe: html in database Pin
AndyInUK16-Sep-10 2:07
AndyInUK16-Sep-10 2:07 
GeneralRe: html in database Pin
cjoki16-Sep-10 7:53
cjoki16-Sep-10 7:53 
AnswerRe: html in database Pin
Luc Pattyn16-Sep-10 9:31
sitebuilderLuc Pattyn16-Sep-10 9:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.