Hi Everybody Please I want to know how can I specify header parameters using mail() function I want to set and usemy own email header, plz tell me how can I do it? like specify "From Name", "Mail From", "Reply-To", "Returnpath", etc.. now I can set just: to, message, subject Thank a lot
You define the headers ahead of calling the mail()-function, and then just pass in the $headers-variable. Read up on php.net: http://php.net/manual/en/function.mail.php Oh, and please don't use subject lines like that. DON'T use @@----- and so on.
Thank you for your reply plz how can I set the From input as I want ? I use this code but not works: $from=$_POST['from']; $headers .= 'From: $from' . "\r\n";
Use this this simple code, <?php $tomail = 'tomail@example.com'; $from = 'PHPAns <admin@yourdomain.com>'; $subject = 'PHP Mail Check'; $headers = 'MIME-Version: 1.0\r\n'; $headers.='Content-type: text/html; charset=iso-8859-1\r\n'; $headers.='From: '.$from.'r\n\'; $message.='Mail Message...'; $mailsent = mail($to, $subj, $message, $headers); mail($tomail, $subject, $message, $headers); ?> PHP:
If you aren't getting what you expect do a var_dump($headers); to see what is actually in the variable Use 'single quotes' if you want exactly that string and you don't want PHP to mess with it Use "double quotes" if you want PHP to look inside the string for a variable to parse To have total control with "double quotes" use {} around the variable - and with arrays you have to or it just won't work Therefore the line I've quoted should have been $headers .= "From: {$from}\r\n"; Code (markup): or the way @sajjadhira put it $headers.='From: '.$from.'r\n\'; Code (markup):
I accept your apology and I am sure @sarahk will, too. However, due to negative connotations of "madam" I am not sure Sarah would like to be called a Madam either..
There are no negative connotations of "madam" in my country, "madam" is a respected word in here, I hope Sarah will accept it. @mmerlinn
@sajjadhira it's all good. @mmerlinn is teasing - after all he's from the country where people say "Yes ma'am" and call their father "sir" Generally though "a madam" runs a whore house and I definitely don't do that!