Jump to content

Recommended Posts

Hi all,

How do I make
[code]$replyemail="info@mycompany.co.uk";[/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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.