redarrow Posted August 9, 2006 Share Posted August 9, 2006 I have been learning to send email to my self but with a attachment i see the attachment but not the message.dont make sence please help cheers.[code]<?php$to="[email protected]";$subject="My news added text file to read";$message ="hi there i am redarrow";$headers ="content-disposition: attachment: filename=john.txt\r\n ";$headers.="content-type: plain/text: ";if(!$send=mail($to,$subject,$message,$headers)){echo "email not sent";}else{echo "email sent!";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/ Share on other sites More sharing options...
SephirGaine Posted August 9, 2006 Share Posted August 9, 2006 Although I can't exactly pinpoint where you went wrong, I can give you what I'm using for an email form-submittal. Hopefully you can take a look as maybe find out where your code might be off? Might be a little bit messy, but I tried to keep it as clean and simple as possible.[code]<?php$EmailFrom = "myemail";$EmailTo = "myemail";$Subject = "Contact Form Submittal";$Name = Trim(stripslashes($_POST['Name'])); $Company = Trim(stripslashes($_POST['Company'])); $Email = Trim(stripslashes($_POST['Email'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $Message = Trim(stripslashes($_POST['Message'])); $validationOK=true;if (Trim($Telephone)=="") $validationOK=false;if (!is_numeric($Telephone)) $validationOK=false;if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit;}$Body = "";$Body .= "Name: ";$Body .= $Name;$Body .= "\n";$Body .= "Company: ";$Body .= $Company;$Body .= "\n";$Body .= "Email: ";$Body .= $Email;$Body .= "\n";$Body .= "Telephone: ";$Body .= $Telephone;$Body .= "\n";$Body .= "Message: ";$Body .= $Message;$Body .= "\n";$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=success.html\">";}else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71586 Share on other sites More sharing options...
hostfreak Posted August 9, 2006 Share Posted August 9, 2006 I am not sure, but for the headers can't you just do:[code]<?php$to="[email protected]";$subject="My news added text file to read";$message ="hi there i am redarrow";$headers .="content-disposition: attachment: filename=john.txt\r\n "."content-type: plain/text: ";if(!$send=mail($to,$subject,$message,$headers)){echo "email not sent";}else{echo "email sent!";}?>[/code]? Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71588 Share on other sites More sharing options...
redarrow Posted August 9, 2006 Author Share Posted August 9, 2006 what i got so far but no message and yes cheers for your code but i am learning ok mate but thank you.[code]<?php$to=$_POST['to'];$subject=$_POST['subject'];$message=$_POST['message'];$headers=$_POST['headers'];$to="[email protected]";$subject="My news added text file to read";$message ="hi there i am redarrow";$headers ="content-disposition: attachment: filename=john.txt\r\n "."content-type: plain/text: ";if(!$send=mail($to,$subject,$message,$headers)){echo "email not sent";}else{echo "email sent!";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71590 Share on other sites More sharing options...
hostfreak Posted August 9, 2006 Share Posted August 9, 2006 Try:[code]<?php$to=$_POST['to'];$subject=$_POST['subject'];$message=$_POST['message'];$headers=$_POST['headers'];$to="[email protected]";$subject="My news added text file to read";$message ="hi there i am redarrow";$headers ="content-disposition: attachment: filename=john.txt\r\n "."content-type: plain/text: ";if(mail($to,$subject,$message,$headers)){echo "email not sent";}else{echo "email sent!";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71592 Share on other sites More sharing options...
redarrow Posted August 9, 2006 Author Share Posted August 9, 2006 tell you what this is a code that lets you send the message then writes the $message varable contents in the file weried init.please delete my email cheers.[code]<?php$to=$_POST['to'];$subject=$_POST['subject'];$message=$_POST['message'];$headers=$_POST['headers'];$to="[email protected]";$subject="My news added text file to read";$message ="hi there i am redarrow";$headers ="content-disposition: attachment: filename=john.txt\r\n "."content-type: plain/text: ";if(!$send=mail($to,$subject,$message,$headers)){echo "email not sent";}else{echo "email sent!";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71596 Share on other sites More sharing options...
redarrow Posted August 9, 2006 Author Share Posted August 9, 2006 thanks for all help i am not doing nothink wrong i have read lots know and theres a rule that if you try to send messages and attachments with php your heading for a headake and just use a url to put the attachment within.so the way i wanted to setup is not pratical unless you no how to but i dont so for example .these two emil example are correct.[code]<?php //send a email normally.if you nedd to add a pic text file ect ect use a url in the message varable.$to="[email protected]";$subject="my news";$message="hi there i am redarrow";$headers="bbc:[email protected]";if(!$send=mail($to,$subject,$message,$headers)){echo "Mail Problam";}else{echo "Mail Sent";}//send a attachment file.$to="[email protected]";$subject="My news added text file to read";$message="john.txt";$a=file_get_contents($file);$headers="content-disposition: attachment: filename=john.txt\r\n ";if(!$send=mail($to,$subject,$message,$headers)){echo "email not sent";}else{echo "email sent!";}[/code][b]admin can you kindly delete my proper email address in the post from other user thank you.[/b] Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71601 Share on other sites More sharing options...
hostfreak Posted August 9, 2006 Share Posted August 9, 2006 Just found this article, http://www.theukwebdesigncompany.com/articles/php-file-attachments.php . I think that will help you with what you want. Link to comment https://forums.phpfreaks.com/topic/16985-solvedemail-help-cheers-learning/#findComment-71681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.