1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

mail() sends with the server email address

Discussion in 'PHP' started by qwikad.com, Jul 27, 2024.

  1. #1
    How do I change it to a custom email?
    ......
    mail($user_email, $subj, $msg, $noreply_email, "ISO-8859-1");

    Instead of sending it with the $noreply_email it sends it with the server email address, something like

    Thanks!
     
    Solved! View solution.
    qwikad.com, Jul 27, 2024 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,202
    Likes Received:
    1,673
    Best Answers:
    29
    Trophy Points:
    475
    #2
    I got it sorted out. It handles it through the "$headers". Something like this:

    $headers = 'From: '.$noreply_email.'';

    ......
    mail($user_email, $subj, $msg, $headers, "ISO-8859-1");
     
    qwikad.com, Jul 27, 2024 IP
    sarahk likes this.
  3. #3
    you should do that
    $user_email = "";
    $subj = "Your Subject Here";
    $subj = "Your Subject Here";
    $noreply_email = "";
    $headers = "From: " . $noreply_email . "\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n";
    mail($user_email, $subj, $msg, $headers);

    This will send the email with the custom email address specified in $noreply_email as the sender.
     
    Last edited: Jul 27, 2024
    zaidzahid, Jul 27, 2024 IP
    sarahk likes this.
  4. GreenHost.Cloud

    GreenHost.Cloud Active Member

    Messages:
    350
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    73
    #4
    To send an email from a custom address instead of the server's default address, you can modify the `mail()` function. Make sure to include the custom email in the headers. Change your code to something like:
    $headers = "From: Your Name <customemail@yourdomain.com>\r
    ";
    mail($user_email, $subj, $msg, $headers, "ISO-8859-1");
    PHP:
     
    GreenHost.Cloud, Jul 28, 2024 IP