Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-12-2005, 05:00 AM   #1 (permalink)
konkhra
Registered User
 
Join Date: Jul 2005
Posts: 6
konkhra is on a distinguished road
Question Mail Editor

Hello,
Can somebody help me with this mail editor? It should work but for some reasons doesn't work.Thanx anticipated.
Mail Editor
konkhra is offline   Reply With Quote
Old 07-12-2005, 06:31 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Quote:
PHP Warning: Wrong parameter count for mail() in mail.php on line 9
From the mail() description:
Quote:
Description
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
Theres no (to, name, from, subject, message, headers) You can't call it like that, but have to make the name and from fit in the header setting.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-12-2005, 12:13 PM   #3 (permalink)
konkhra
Registered User
 
Join Date: Jul 2005
Posts: 6
konkhra is on a distinguished road
Thank you very much redhead for your reply.
hesre is my new php script:

<?
$name = stripslashes($_POST['name']);
$from = stripslashes($_POST['from']);
$to = stripslashes($_POST['to']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);
$headers .= "From: \"".$name."\" <"$from">\r";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
if(mail($to,$subject,$message,$headers)){;
echo "Mail has been sent.";
}
else{
echo "Mail has not been sent.";
}
?>

It's working but with a little problem.The sender address it's shown strange.
And one more question.Can I change the order of the variables when it's sending mail? Ex. instead of if(mail($to,$subject,$message,$headers) to be like this if(mail($headers ,$to, $subject,$message) ... i've tried this method and it seems that the mail was sent successfully but it didn't arrived in mailbox .
konkhra is offline   Reply With Quote
Old 07-12-2005, 12:20 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
what exactly do you mean by the sender adress is shown strange?

the order of the mail() arguments can not be changed. it's a built-in PHP function.
__________________
Mike
sde is offline   Reply With Quote
Old 07-12-2005, 12:30 PM   #5 (permalink)
konkhra
Registered User
 
Join Date: Jul 2005
Posts: 6
konkhra is on a distinguished road
Now it's working fine.
Before to post the reply i tried to send an email and in Name field I've put "Thomas Allyson: Drums" without quote and in mailbox was something like this "Thomas Allyson: Drums@yahoo.com" the email was sent to merant073@yahoo.com , my email address.Now I see that it's working fine.Thank you again for your help
konkhra is offline   Reply With Quote
Old 07-12-2005, 12:41 PM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Quote:
The sender address it's shown strange.
PHP Code:
$headers .= "From: \"".$name."\" <"$from">\r"
Your header definition is your flaw here, the from should be:
PHP Code:
$headers .= "From: \"".$name."\" <".$from.">\r\n"
Any line in your header should be formed with a \r\n as your End Of Line. Only the very last line in the header shouldn't have a newline char.
Something like this:
PHP Code:
<?
$name 
stripslashes($_POST['name']);
$from stripslashes($_POST['from']);
$to stripslashes($_POST['to']);
$subject stripslashes($_POST['subject']);
$message stripslashes($_POST['message']);
$headers .= "From: \"".$name."\" <".$from.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1";
if(
mail($to,$subject,$message,$headers)){
    echo 
"Mail has been sent.";
}
else{
    echo 
"Mail has not been sent.";
}
?>
Quote:
And one more question.Can I change the order of the variables when it's sending mail? Ex. instead of
PHP Code:
if(mail($to,$subject,$message,$headers
to be like this
PHP Code:
if(mail($headers ,$to$subject,$message
In short NO Since you can form your header any way you want to, the php-mailer needs to know exactly what to address and what subject to parse onto sendmail (or what ever mailerdeamon the system is running) there for the very first argument to mail() must be a correct address to send teh mail to, adn the second argument must be a type of orriginal header.
You shipped header can be formed in any way you like, it will only fool the recieving mail-client, telling it what you told your sending mail-server to ship as the header, in order to disguise any not intended orriginated address, if your sender usualy stamps teh outgoing messages with From: Average joe <joe.barneby@mydomain.com> but you want an intentional reply from the reciever to munge up in your usual <info@mydomain.com> address, and not be send to your usual login name joe.barneby . Then you form the header with that info, the php-mailer then forges the outgoing message to be orriginated from the info sender, instead of the mailer-deamons usual task of fetching the current caller-ID from the login-pool.

An example of that could be:
PHP Code:
$header "From: Mailform <noreply@{$_SERVER['SERVER_NAME']}>\r\n";
$header =."Reply-To: <" stripslashers($_POST['from']) .">\r\n";
$header =. "X-Mailer: PHP/" phpversion();
mail(stripslashes($_POST['to']), stripslashes($_POST['subject']),
        
stripslashes($_POST['message'], $header); 
Now the mail that is beeing send, tells the recievers email program that it orriginates from your Mailform, but on replys it should send it to the posted email the submitter posted, yet the server running on your site might be running as 'www' yet noone will ever know that.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-12-2005, 12:48 PM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Hmmm.. I see I was a little late since Mike steped in.. But the missing .(dot's) around the $from and the malformed \r\n newlines in your header buildup will improve on it.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-12-2005, 12:50 PM   #8 (permalink)
konkhra
Registered User
 
Join Date: Jul 2005
Posts: 6
konkhra is on a distinguished road
Wow.That's a good help.Thank you again for your help guys.
konkhra is offline   Reply With Quote
Old 07-12-2005, 12:53 PM   #9 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Quote:
Wow.That's a good help.Thank you again for your help guys.
Feel free to ask anytime you encounter something that isn't quite following your orriginal thoughts.

Kepp up the good work, any practice makes it only better with time.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Specifying SMTP server for PHP mail() Epsilon PHP 2 03-18-2004 12:20 AM
E mail Bombed NOT FOR KIDS (Rated R) Eyelfixit Lounge 10 07-09-2003 10:13 AM
Stable Graphical FTP Client, HTML editor, & Image Manipulation for RedHat 7.3? Admin Linux / BSD / OS X 2 08-30-2002 04:55 PM


All times are GMT -8. The time now is 11:05 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting