Reputation: 3118
I'm using iPage for my website, and I'm using a simple mail() method to send test mails from my page. On iPage, I have email capabilities via [email protected]. But when I send an email out, it comes from the iPage server and is sent from [email protected], which is quite ugly looking!
Is there a way I can use the mail() method in php to send an email from my page that will use the shorter sender above? Thanks for any and all help!
Upvotes: 1
Views: 914
Reputation: 22711
Try this, You can add the From header to customise the sender address.
$from ='[email protected]';
$headers = 'From: ' . $from . "\r\n";
...
mail($to, $subject, $message, $headers);
Upvotes: 2
Reputation: 4218
you need to add a header named From. this code will send with the mail address [email protected]:
$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);
Upvotes: 5