Jump to content

[SOLVED] FormMail


johnpdmccall

Recommended Posts

Hi all,

How do I make
[code]$replyemail="[email protected]";[/code]
appear as "My Company Name"
in the 'From' part of an e'mail.

The line of code above is part of some PHP that e-mails me the results of a contact form and sends the user a copy. I'd like the user to see my company name.

Many thanks
John

:)

Link to comment
https://forums.phpfreaks.com/topic/30105-solved-formmail/
Share on other sites

You will have to define it in a header, "a should be minimum"-example:

[code]
<?php

$headers = "From: $from_name <$from_email>\r\n"; // <-- This one sets the FROM name
$headers .= "Reply-To: $from_name <$from_email>\r\n";
$headers .= "Return-Path: $from_name <$from_email>\r\n";
$headers .= "X-Mailer: PHP v".phpversion()."\r\n";

mail($to_email, $subject, $message, $headers);

// or mail with the fifth parameter set, not all setups allow it but it sets the correct return adress

mail($to_email, $subject, $message, $headers "-f" . $from_email);

// for instance, running php in safe mode disallows the fifth parameter, a simple if test determines the proper way

if(ini_get('safe_mode'))
{
  mail($to_email, $subject, $message, $headers);
}
else
{
  mail($to_email, $subject, $message, $headers "-f" . $from_email);
}

?>
[/code]

Hope this helps
Link to comment
https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138417
Share on other sites

Archived

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

×
×
  • Create New...

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.