Jump to content

Send email from host server


HardCoreMore

Recommended Posts

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 hardcore@host.turnkeyhostings.com. How can i choose to send email from my domain name hardcore@mysupercashcow.info. 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("caslav.sabani@gmail.com",$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
Share on other sites

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
Share on other sites

Change this line...

$headers .= 'From: Your Name/Company name here <$from>';

 

to...

 

$headers .= 'From: Company name here <hardcode@host.turnkeyhostings.com>';

 

Make sure you change company name here to your company name or your own name.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.