Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

[solved]email help cheers learning.

Recommended Posts

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="me@me.com";
$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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
I am not sure, but for the headers can't you just do:

[code]
<?php
$to="me@me.com";
$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]
?

Share this post


Link to post
Share on other sites
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="me@me.com";
$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]

Share this post


Link to post
Share on other sites
Try:

[code]
<?php

$to=$_POST['to'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$headers=$_POST['headers'];

$to="email@email.com";
$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]

Share this post


Link to post
Share on other sites
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="me@me.com";
$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]

Share this post


Link to post
Share on other sites
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="me@me.com";
$subject="my news";
$message="hi there i am redarrow";
$headers="bbc:admin@freesinflesmail.ath.cx";
if(!$send=mail($to,$subject,$message,$headers)){

echo "Mail Problam";

}else{

echo "Mail Sent";

}



//send a attachment file.



$to="me@me.com";
$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]

Share this post


Link to post
Share on other sites
Just found this article, http://www.theukwebdesigncompany.com/articles/php-file-attachments.php . I think that will help you with what you want.

Share this post


Link to post
Share on other sites

×

Important Information

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.