Jump to content

mail() I want it to send a specific sender email and not the server's email


samoi

Recommended Posts

hello guys !

 

if (isset($_POST['submit'])) {
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $users = "SELECT email FROM gb";
    $result = mysql_query($users) or die(mysql_error());


    while ($me = mysql_fetch_assoc($result)) {
        if (mail($me['email'], $subject, $message)) {
            echo $me['user'];
            echo "-----";
            echo $me['email'];
            echo "---- Has been contacted<br />";
        } else {
            echo "Failed";
        }
    }
}

 

I need it to work as follow:

 

when I send the email FOR EXAMPLE to ME, I receive a long email address, actually it's the server's default email address

 

any help ?

Set the appropriate headers:

Found on the manual site, example 2

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

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.