HardCoreMore Posted March 11, 2008 Share Posted March 11, 2008 I am learning php now and i learn how to send email with php. Now, i have my domain name www.mysupercashcow.info that i am using with hosting company turnkeyhostings.com. I made my email account on that hosting control panel that name is hardcore and when i send email the script works fine but when i check out email i see that it has been sent from [email protected]. How can i choose to send email from my domain name [email protected]. This is the script that i am using <?php if (isset($_POST["userEmail"])){ $to = $_POST["userEmail"]; $subject = $_POST["userSubject"]; $message = $_POST["userMessage"]; $from = $_POST["userEmail"]; $spam= $_POST["spam"]; $name = $_POST["userName"]; mail("[email protected]",$subject,"$from<br />$name<br />$message<br />$spam<br />"); echo "Your message has been sent"; } else{ echo "You didn't enter email!"; } ?> Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/ Share on other sites More sharing options...
ILYAS415 Posted March 11, 2008 Share Posted March 11, 2008 One second im just getting the code from my server Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490011 Share on other sites More sharing options...
HardCoreMore Posted March 11, 2008 Author Share Posted March 11, 2008 Ok, no problem. Thanks man! Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490012 Share on other sites More sharing options...
ILYAS415 Posted March 11, 2008 Share Posted March 11, 2008 Okay heres the code, it also lets you put html into your emails. <? $from= $_POST['userEmail']; $to= $_POST['userEmail']; $headers="MIME-Version:1.0 \r\n"; $headers .= "Content-type: text/html;charset=iso-8859-1 \r\n"; $headers .= 'From: Your Name/Company name here <$from>'; $subject = $_POST['userSubject']; $message = $_POST['userMessage']; mail($to, $subject, $message, $headers); ?> Tried to make it suit your code as much as possible Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490019 Share on other sites More sharing options...
HardCoreMore Posted March 11, 2008 Author Share Posted March 11, 2008 Ok but where do you exactly specify from which email it will send the message. Because with this code it will send it from [email protected] again. Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490034 Share on other sites More sharing options...
ILYAS415 Posted March 11, 2008 Share Posted March 11, 2008 Change this line... $headers .= 'From: Your Name/Company name here <$from>'; to... $headers .= 'From: Company name here <[email protected]>'; Make sure you change company name here to your company name or your own name. Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490035 Share on other sites More sharing options...
HardCoreMore Posted March 11, 2008 Author Share Posted March 11, 2008 It still send me emails from [email protected] instead [email protected] Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490041 Share on other sites More sharing options...
HardCoreMore Posted March 12, 2008 Author Share Posted March 12, 2008 I didn't check it right. It works without problem. Thanks again man. Link to comment https://forums.phpfreaks.com/topic/95704-send-email-from-host-server/#findComment-490073 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.