Search code examples
phpemailheaderemail-headers

how to change mailed by default value in the email header


I want to give mailed by value as my domain name (xyz.com) in the email header, instead of challenger websitewelcome.com, etc. And also I want to change from email id in the email header. How can I solve the above problem, I am using PHP script to send an email. Thanks in advance.


Solution

  • Please find the following code, I hope it will solve your problem

    <?php
    $to = "[email protected]"; // To address email id
    $subject = "My subject";
    $txt = "Hello world!";
    $headers = "From: your company name <[email protected]> \r\n"; // from email address
    mail($to,$subject,$txt,$headers,"[email protected]"); // this will remove mailed by default value to your domainname
    ?>
    

    Note in the mail function last parameter is mandatory "-f" //[email protected] need to be add without space