Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在注册cpanel中更改发件人邮件_Php_Cpanel - Fatal编程技术网

Php 在注册cpanel中更改发件人邮件

Php 在注册cpanel中更改发件人邮件,php,cpanel,Php,Cpanel,我有一张从clevertech网站获取的注册表,如下所示,它正在向新用户发送邮件验证,用户正在接收邮件,一切正常,但是:用户接收的邮件发件人为:my_用户名_cpanel@p3plcpnl0232.prod.phx3.secureserver.net 我想让它从我的一个电子邮件帐户发送邮件,比如register@mysite.com相反 下面是我的PHP代码 <?php /* Registration process, inserts user info into the database

我有一张从clevertech网站获取的注册表,如下所示,它正在向新用户发送邮件验证,用户正在接收邮件,一切正常,但是:用户接收的邮件发件人为:my_用户名_cpanel@p3plcpnl0232.prod.phx3.secureserver.net

我想让它从我的一个电子邮件帐户发送邮件,比如register@mysite.com相反 下面是我的PHP代码

<?php /* Registration process, inserts user info into the database 
and sends account confirmation email message */

// Set session variables to be used on profile.php page
$_SESSION['email'] = $_POST['email'];
$_SESSION['first_name'] = $_POST['firstname'];
$_SESSION['last_name'] = $_POST['lastname'];

$_SESSION['City'] = $_POST['City'];
$_SESSION['Postal'] = $_POST['Postal'];

$_SESSION['Street'] = $_POST['Street'];
$_SESSION['buildingNo'] = $_POST['buildingNo'];

$_SESSION['phone'] = $_POST['phone'];
$_SESSION['noteadress'] = $_POST['noteadress'];


// Escape all $_POST variables to protect against SQL injections
$first_name = $mysqli->escape_string($_POST['firstname']);
$last_name = $mysqli->escape_string($_POST['lastname']);

$City = $mysqli->escape_string($_POST['City']);
$Postal = $mysqli->escape_string($_POST['Postal']);

$Street = $mysqli->escape_string($_POST['Street']);
$buildingNo = $mysqli->escape_string($_POST['buildingNo']);

$phone = $mysqli->escape_string($_POST['phone']);
$noteadress = $mysqli->escape_string($_POST['noteadress']);

$email = $mysqli->escape_string($_POST['email']);
$password = $mysqli->escape_string(password_hash($_POST['password'], 
PASSWORD_BCRYPT));
$hash = $mysqli->escape_string( md5( rand(0,1000) ) );

// Check if user with that email already exists
$result = $mysqli->query("SELECT * FROM customer WHERE email='$email'") or die($mysqli->error());

// We know user email exists if the rows returned are more than 0
if ( $result->num_rows > 0 ) {

$_SESSION['message'] = 'User with this email already exists!';
header("location: error.php"); 
}
else { // Email doesn't already exist in a database, proceed...

// active is 0 by DEFAULT (no need to include it here)
$sql = "INSERT INTO customer (first_name, last_name, email, password, 
hash,Street,City,buildingNo,Noteadress,Postal,phone) " 
        . "VALUES ('$first_name','$last_name','$email','$password', '$hash', 
'$Street','$City','$buildingNo','$Noteadress','$Postal','$phone')";

// Add user to the database
if ( $mysqli->query($sql) ){

    $_SESSION['active'] = 0; //0 until user activates their account with 
verify.php
    $_SESSION['logged_in'] = true; // So we know the user has logged in
    $_SESSION['message'] =

             "Confirmation link has been sent to $email, please verify
             your account by clicking on the link in the message!";

    // Send registration confirmation link (verify.php)
    $to      = $email;
    $subject = 'Account Verification ( MereBuy.com )';
    $message_body = '
    Hello '.$first_name.',

    Thank you for signing up!

    Please click this link to activate your account:

    mywebsite.com/verify.php?email='.$email.'&hash='.$hash;  

    mail( $to, $subject, $message_body );

    header("location: profile.php"); 

}

else {
    $_SESSION['message'] = 'Registration failed,Or first Name Exist!';
    header("location: error.php");
}

}
您需要在电子邮件中添加s标题

这通常用于添加额外的标头(从、抄送和密件抄送)

您需要在电子邮件中添加s标题

这通常用于添加额外的标头(从、抄送和密件抄送)


谢谢Masivuye Cokile,它正在按预期工作,仍然在标题中,它是这样来的:notifications@yourdomain.com通过p3plcpnl0732.prod.phx3.secureserver.net,但它比以前更好。谢谢Masivuye Cokile,它正在按预期工作,仍然在标题中,它是这样来的:notifications@yourdomain.com通过p3plcpnl0732.prod.phx3.secureserver.net,但它比以前更好。
 $header = "MIME-Version: 1.0" . "\r\n";
 $header .= "Content-type:text/html;charset=UTF-8" . "\r\n";
 $header .= 'From: YOUR Website Name <notifications@yourdomain.com>' . "\r\n";
mail( $to, $subject, $message_body,$header);