John
John

Reputation: 4944

Outgoing email address on server with Plesk

I have Plesk with a Network Solutions virtual server. When my site sends out emails using PHP, the email header indicates that the message is coming from an address like this one:

[email protected]

How do I change this address?

Upvotes: 1

Views: 496

Answers (1)

mti2935
mti2935

Reputation: 12027

Using the PHP mail() command, you can set the envelope from address using the -f command, and you can include the from address in the message headers as well, like so:

    $to = "[email protected]";
    $from = "[email protected]";
    $subject = "subject";
    $message = "this is the message body";

    $headers = "From: $from"; 
    $ok = @mail($to, $subject, $message, $headers, "-f " . $from);   

Upvotes: 2

Related Questions