mail() is Incorrectly Sending Emails to cPanel Default Account
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I purchased a domain from GoDaddy and linked it to Office 365 (via MX records). This means I have several email accounts in Outlook that are @mydomain.com.
Example Outlook accounts:
- sales@mydomain.com
- contact@mydomain.com
- matt@mydomain.com
I can send/receive emails through those accounts.
My website is hosted on basic web hosting with a cPanel installation, which means I was given a "default" email account. For example: default@mydomain.com
. I wrote a PHP script on my website (contact form) that sends emails via mail()
to contact@mydomain.com
.
However all the emails are sent to the default cPanel account default@mydomain.com
instead of the Outlook account contact@mydomain.com
.
To test, I tried sending the emails to my personal account that is not hosted on mydomain and it works as expected. Emails are sent instantly.
How come my website incorrectly send emails to the Outlook accounts? Thanks for your time.
EDIT:
The script was requested:
<?php
$uploadedFile = $statusMsg = '';
if (isset($_POST['submit']))
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
if(!empty($first_name) && !empty($last_name) && !empty($message))
{
if(filter_var($email, FILTER_VALIDATE_EMAIL))
{
$uploadStatus = 1;
if(!empty($_FILES["attach"]["name"]))
{
$targetDir = "uploads/";
$fileName = basename($_FILES["attach"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["attach"]["tmp_name"], $targetFilePath))
{
$uploadedFile = $targetFilePath;
}
else
{
$uploadStatus = 0;
$statusMsg = "Sorry, there was an error uploading your file.";
}
}
if($uploadStatus == 1)
{
$name = $first_name.' '.$last_name;
$mailTo = "contact@mydomain.com";//changed to my real outlook account
$htmlContent = '<h2>Contact Request Submitted</h2>
<p><b>Name:</b> '.$name.'</p>
<p><b>Email:</b> '.$email.'</p>
<p><b>Phone:</b> '.$phone.'</p>
<p><b>Message:</b><br/>'.$message.'</p>';
// Header for sender info
$headers = "From: $name"." <".$email.">";
if(!empty($uploadedFile) && file_exists($uploadedFile))
{
// Boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Headers for attachment
$headers .= "nMIME-Version: 1.0n" . "Content-Type: multipart/mixed;n" . " boundary="{$mime_boundary}"";
// Multipart boundary
$message = "--{$mime_boundary}n" . "Content-Type: text/html; charset="UTF-8"n" .
"Content-Transfer-Encoding: 7bitnn" . $htmlContent . "nn";
// Preparing attachment
if(is_file($uploadedFile)){
$message .= "--{$mime_boundary}n";
$fp = @fopen($uploadedFile,"rb");
$data = @fread($fp,filesize($uploadedFile));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name="".basename($uploadedFile).""n" .
"Content-Description: ".basename($uploadedFile)."n" .
"Content-Disposition: attachment;n" . " filename="".basename($uploadedFile).""; size=".filesize($uploadedFile).";n" .
"Content-Transfer-Encoding: base64nn" . $data . "nn";
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $email;
// Send email
$mail = mail($mailTo, "Contact Form Submission from ".$name, $message, $headers, $returnpath);
// Delete attachment file from the server
@unlink($uploadedFile);
}
else
{
// Set content-type header for sending HTML email
$headers .= "rn". "MIME-Version: 1.0";
$headers .= "rn". "Content-type:text/html;charset=UTF-8";
// Send email
$mail = mail($mailTo, 'Contact Form Submission from '.$name, $htmlContent, $headers);
}
// If mail sent
if($mail)
{
$statusMsg = "Your message has been sent. Thanks!";
}
else
{
$statusMsg = 'Your contact request submission failed, please try again.';
}
}
}
else
{
$statusMsg = 'Please enter a valid email address.';
}
}
else
{
$statusMsg = "Please fill out the required information.";
}
}
?>
php email mx-record
|
show 6 more comments
I purchased a domain from GoDaddy and linked it to Office 365 (via MX records). This means I have several email accounts in Outlook that are @mydomain.com.
Example Outlook accounts:
- sales@mydomain.com
- contact@mydomain.com
- matt@mydomain.com
I can send/receive emails through those accounts.
My website is hosted on basic web hosting with a cPanel installation, which means I was given a "default" email account. For example: default@mydomain.com
. I wrote a PHP script on my website (contact form) that sends emails via mail()
to contact@mydomain.com
.
However all the emails are sent to the default cPanel account default@mydomain.com
instead of the Outlook account contact@mydomain.com
.
To test, I tried sending the emails to my personal account that is not hosted on mydomain and it works as expected. Emails are sent instantly.
How come my website incorrectly send emails to the Outlook accounts? Thanks for your time.
EDIT:
The script was requested:
<?php
$uploadedFile = $statusMsg = '';
if (isset($_POST['submit']))
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
if(!empty($first_name) && !empty($last_name) && !empty($message))
{
if(filter_var($email, FILTER_VALIDATE_EMAIL))
{
$uploadStatus = 1;
if(!empty($_FILES["attach"]["name"]))
{
$targetDir = "uploads/";
$fileName = basename($_FILES["attach"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["attach"]["tmp_name"], $targetFilePath))
{
$uploadedFile = $targetFilePath;
}
else
{
$uploadStatus = 0;
$statusMsg = "Sorry, there was an error uploading your file.";
}
}
if($uploadStatus == 1)
{
$name = $first_name.' '.$last_name;
$mailTo = "contact@mydomain.com";//changed to my real outlook account
$htmlContent = '<h2>Contact Request Submitted</h2>
<p><b>Name:</b> '.$name.'</p>
<p><b>Email:</b> '.$email.'</p>
<p><b>Phone:</b> '.$phone.'</p>
<p><b>Message:</b><br/>'.$message.'</p>';
// Header for sender info
$headers = "From: $name"." <".$email.">";
if(!empty($uploadedFile) && file_exists($uploadedFile))
{
// Boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Headers for attachment
$headers .= "nMIME-Version: 1.0n" . "Content-Type: multipart/mixed;n" . " boundary="{$mime_boundary}"";
// Multipart boundary
$message = "--{$mime_boundary}n" . "Content-Type: text/html; charset="UTF-8"n" .
"Content-Transfer-Encoding: 7bitnn" . $htmlContent . "nn";
// Preparing attachment
if(is_file($uploadedFile)){
$message .= "--{$mime_boundary}n";
$fp = @fopen($uploadedFile,"rb");
$data = @fread($fp,filesize($uploadedFile));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name="".basename($uploadedFile).""n" .
"Content-Description: ".basename($uploadedFile)."n" .
"Content-Disposition: attachment;n" . " filename="".basename($uploadedFile).""; size=".filesize($uploadedFile).";n" .
"Content-Transfer-Encoding: base64nn" . $data . "nn";
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $email;
// Send email
$mail = mail($mailTo, "Contact Form Submission from ".$name, $message, $headers, $returnpath);
// Delete attachment file from the server
@unlink($uploadedFile);
}
else
{
// Set content-type header for sending HTML email
$headers .= "rn". "MIME-Version: 1.0";
$headers .= "rn". "Content-type:text/html;charset=UTF-8";
// Send email
$mail = mail($mailTo, 'Contact Form Submission from '.$name, $htmlContent, $headers);
}
// If mail sent
if($mail)
{
$statusMsg = "Your message has been sent. Thanks!";
}
else
{
$statusMsg = 'Your contact request submission failed, please try again.';
}
}
}
else
{
$statusMsg = 'Please enter a valid email address.';
}
}
else
{
$statusMsg = "Please fill out the required information.";
}
}
?>
php email mx-record
We need more details, starting from code with mail sending.
– Oen44
Jan 4 at 0:38
It's a big script with support for email attachments and it works with any "to" address I give it. but sure, I'll edit.
– mrg95
Jan 4 at 0:39
2
Talk to your host. Chances are that they configured your domain for mail on that same server. Most MTAs will never even look at DNS if the domain exists locally.
– Sammitch
Jan 4 at 0:40
It's just to make sure that the script is correct to exclude possible cause of the problem.
– Oen44
Jan 4 at 0:41
4
Avoid usingmail()
in PHP anyway for many reasons. Ideally you should use a commercial-grade email gateway such as (and this is not an endorsment) SendGrid, which have a Web-service for sending email which is more reliable than PHP'smail()
or attempting to use SMTP directly from PHP. For example: sendgrid.com/docs/for-developers/sending-email/…
– Dai
Jan 4 at 0:43
|
show 6 more comments
I purchased a domain from GoDaddy and linked it to Office 365 (via MX records). This means I have several email accounts in Outlook that are @mydomain.com.
Example Outlook accounts:
- sales@mydomain.com
- contact@mydomain.com
- matt@mydomain.com
I can send/receive emails through those accounts.
My website is hosted on basic web hosting with a cPanel installation, which means I was given a "default" email account. For example: default@mydomain.com
. I wrote a PHP script on my website (contact form) that sends emails via mail()
to contact@mydomain.com
.
However all the emails are sent to the default cPanel account default@mydomain.com
instead of the Outlook account contact@mydomain.com
.
To test, I tried sending the emails to my personal account that is not hosted on mydomain and it works as expected. Emails are sent instantly.
How come my website incorrectly send emails to the Outlook accounts? Thanks for your time.
EDIT:
The script was requested:
<?php
$uploadedFile = $statusMsg = '';
if (isset($_POST['submit']))
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
if(!empty($first_name) && !empty($last_name) && !empty($message))
{
if(filter_var($email, FILTER_VALIDATE_EMAIL))
{
$uploadStatus = 1;
if(!empty($_FILES["attach"]["name"]))
{
$targetDir = "uploads/";
$fileName = basename($_FILES["attach"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["attach"]["tmp_name"], $targetFilePath))
{
$uploadedFile = $targetFilePath;
}
else
{
$uploadStatus = 0;
$statusMsg = "Sorry, there was an error uploading your file.";
}
}
if($uploadStatus == 1)
{
$name = $first_name.' '.$last_name;
$mailTo = "contact@mydomain.com";//changed to my real outlook account
$htmlContent = '<h2>Contact Request Submitted</h2>
<p><b>Name:</b> '.$name.'</p>
<p><b>Email:</b> '.$email.'</p>
<p><b>Phone:</b> '.$phone.'</p>
<p><b>Message:</b><br/>'.$message.'</p>';
// Header for sender info
$headers = "From: $name"." <".$email.">";
if(!empty($uploadedFile) && file_exists($uploadedFile))
{
// Boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Headers for attachment
$headers .= "nMIME-Version: 1.0n" . "Content-Type: multipart/mixed;n" . " boundary="{$mime_boundary}"";
// Multipart boundary
$message = "--{$mime_boundary}n" . "Content-Type: text/html; charset="UTF-8"n" .
"Content-Transfer-Encoding: 7bitnn" . $htmlContent . "nn";
// Preparing attachment
if(is_file($uploadedFile)){
$message .= "--{$mime_boundary}n";
$fp = @fopen($uploadedFile,"rb");
$data = @fread($fp,filesize($uploadedFile));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name="".basename($uploadedFile).""n" .
"Content-Description: ".basename($uploadedFile)."n" .
"Content-Disposition: attachment;n" . " filename="".basename($uploadedFile).""; size=".filesize($uploadedFile).";n" .
"Content-Transfer-Encoding: base64nn" . $data . "nn";
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $email;
// Send email
$mail = mail($mailTo, "Contact Form Submission from ".$name, $message, $headers, $returnpath);
// Delete attachment file from the server
@unlink($uploadedFile);
}
else
{
// Set content-type header for sending HTML email
$headers .= "rn". "MIME-Version: 1.0";
$headers .= "rn". "Content-type:text/html;charset=UTF-8";
// Send email
$mail = mail($mailTo, 'Contact Form Submission from '.$name, $htmlContent, $headers);
}
// If mail sent
if($mail)
{
$statusMsg = "Your message has been sent. Thanks!";
}
else
{
$statusMsg = 'Your contact request submission failed, please try again.';
}
}
}
else
{
$statusMsg = 'Please enter a valid email address.';
}
}
else
{
$statusMsg = "Please fill out the required information.";
}
}
?>
php email mx-record
I purchased a domain from GoDaddy and linked it to Office 365 (via MX records). This means I have several email accounts in Outlook that are @mydomain.com.
Example Outlook accounts:
- sales@mydomain.com
- contact@mydomain.com
- matt@mydomain.com
I can send/receive emails through those accounts.
My website is hosted on basic web hosting with a cPanel installation, which means I was given a "default" email account. For example: default@mydomain.com
. I wrote a PHP script on my website (contact form) that sends emails via mail()
to contact@mydomain.com
.
However all the emails are sent to the default cPanel account default@mydomain.com
instead of the Outlook account contact@mydomain.com
.
To test, I tried sending the emails to my personal account that is not hosted on mydomain and it works as expected. Emails are sent instantly.
How come my website incorrectly send emails to the Outlook accounts? Thanks for your time.
EDIT:
The script was requested:
<?php
$uploadedFile = $statusMsg = '';
if (isset($_POST['submit']))
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
if(!empty($first_name) && !empty($last_name) && !empty($message))
{
if(filter_var($email, FILTER_VALIDATE_EMAIL))
{
$uploadStatus = 1;
if(!empty($_FILES["attach"]["name"]))
{
$targetDir = "uploads/";
$fileName = basename($_FILES["attach"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["attach"]["tmp_name"], $targetFilePath))
{
$uploadedFile = $targetFilePath;
}
else
{
$uploadStatus = 0;
$statusMsg = "Sorry, there was an error uploading your file.";
}
}
if($uploadStatus == 1)
{
$name = $first_name.' '.$last_name;
$mailTo = "contact@mydomain.com";//changed to my real outlook account
$htmlContent = '<h2>Contact Request Submitted</h2>
<p><b>Name:</b> '.$name.'</p>
<p><b>Email:</b> '.$email.'</p>
<p><b>Phone:</b> '.$phone.'</p>
<p><b>Message:</b><br/>'.$message.'</p>';
// Header for sender info
$headers = "From: $name"." <".$email.">";
if(!empty($uploadedFile) && file_exists($uploadedFile))
{
// Boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Headers for attachment
$headers .= "nMIME-Version: 1.0n" . "Content-Type: multipart/mixed;n" . " boundary="{$mime_boundary}"";
// Multipart boundary
$message = "--{$mime_boundary}n" . "Content-Type: text/html; charset="UTF-8"n" .
"Content-Transfer-Encoding: 7bitnn" . $htmlContent . "nn";
// Preparing attachment
if(is_file($uploadedFile)){
$message .= "--{$mime_boundary}n";
$fp = @fopen($uploadedFile,"rb");
$data = @fread($fp,filesize($uploadedFile));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name="".basename($uploadedFile).""n" .
"Content-Description: ".basename($uploadedFile)."n" .
"Content-Disposition: attachment;n" . " filename="".basename($uploadedFile).""; size=".filesize($uploadedFile).";n" .
"Content-Transfer-Encoding: base64nn" . $data . "nn";
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $email;
// Send email
$mail = mail($mailTo, "Contact Form Submission from ".$name, $message, $headers, $returnpath);
// Delete attachment file from the server
@unlink($uploadedFile);
}
else
{
// Set content-type header for sending HTML email
$headers .= "rn". "MIME-Version: 1.0";
$headers .= "rn". "Content-type:text/html;charset=UTF-8";
// Send email
$mail = mail($mailTo, 'Contact Form Submission from '.$name, $htmlContent, $headers);
}
// If mail sent
if($mail)
{
$statusMsg = "Your message has been sent. Thanks!";
}
else
{
$statusMsg = 'Your contact request submission failed, please try again.';
}
}
}
else
{
$statusMsg = 'Please enter a valid email address.';
}
}
else
{
$statusMsg = "Please fill out the required information.";
}
}
?>
php email mx-record
php email mx-record
edited Jan 4 at 0:40
mrg95
asked Jan 4 at 0:36
mrg95mrg95
66712154
66712154
We need more details, starting from code with mail sending.
– Oen44
Jan 4 at 0:38
It's a big script with support for email attachments and it works with any "to" address I give it. but sure, I'll edit.
– mrg95
Jan 4 at 0:39
2
Talk to your host. Chances are that they configured your domain for mail on that same server. Most MTAs will never even look at DNS if the domain exists locally.
– Sammitch
Jan 4 at 0:40
It's just to make sure that the script is correct to exclude possible cause of the problem.
– Oen44
Jan 4 at 0:41
4
Avoid usingmail()
in PHP anyway for many reasons. Ideally you should use a commercial-grade email gateway such as (and this is not an endorsment) SendGrid, which have a Web-service for sending email which is more reliable than PHP'smail()
or attempting to use SMTP directly from PHP. For example: sendgrid.com/docs/for-developers/sending-email/…
– Dai
Jan 4 at 0:43
|
show 6 more comments
We need more details, starting from code with mail sending.
– Oen44
Jan 4 at 0:38
It's a big script with support for email attachments and it works with any "to" address I give it. but sure, I'll edit.
– mrg95
Jan 4 at 0:39
2
Talk to your host. Chances are that they configured your domain for mail on that same server. Most MTAs will never even look at DNS if the domain exists locally.
– Sammitch
Jan 4 at 0:40
It's just to make sure that the script is correct to exclude possible cause of the problem.
– Oen44
Jan 4 at 0:41
4
Avoid usingmail()
in PHP anyway for many reasons. Ideally you should use a commercial-grade email gateway such as (and this is not an endorsment) SendGrid, which have a Web-service for sending email which is more reliable than PHP'smail()
or attempting to use SMTP directly from PHP. For example: sendgrid.com/docs/for-developers/sending-email/…
– Dai
Jan 4 at 0:43
We need more details, starting from code with mail sending.
– Oen44
Jan 4 at 0:38
We need more details, starting from code with mail sending.
– Oen44
Jan 4 at 0:38
It's a big script with support for email attachments and it works with any "to" address I give it. but sure, I'll edit.
– mrg95
Jan 4 at 0:39
It's a big script with support for email attachments and it works with any "to" address I give it. but sure, I'll edit.
– mrg95
Jan 4 at 0:39
2
2
Talk to your host. Chances are that they configured your domain for mail on that same server. Most MTAs will never even look at DNS if the domain exists locally.
– Sammitch
Jan 4 at 0:40
Talk to your host. Chances are that they configured your domain for mail on that same server. Most MTAs will never even look at DNS if the domain exists locally.
– Sammitch
Jan 4 at 0:40
It's just to make sure that the script is correct to exclude possible cause of the problem.
– Oen44
Jan 4 at 0:41
It's just to make sure that the script is correct to exclude possible cause of the problem.
– Oen44
Jan 4 at 0:41
4
4
Avoid using
mail()
in PHP anyway for many reasons. Ideally you should use a commercial-grade email gateway such as (and this is not an endorsment) SendGrid, which have a Web-service for sending email which is more reliable than PHP's mail()
or attempting to use SMTP directly from PHP. For example: sendgrid.com/docs/for-developers/sending-email/…– Dai
Jan 4 at 0:43
Avoid using
mail()
in PHP anyway for many reasons. Ideally you should use a commercial-grade email gateway such as (and this is not an endorsment) SendGrid, which have a Web-service for sending email which is more reliable than PHP's mail()
or attempting to use SMTP directly from PHP. For example: sendgrid.com/docs/for-developers/sending-email/…– Dai
Jan 4 at 0:43
|
show 6 more comments
1 Answer
1
active
oldest
votes
The solution was to change my cPanel "Email Routing" option to "Remote" in order for all local emails to first check with the MX records.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54031724%2fmail-is-incorrectly-sending-emails-to-cpanel-default-account%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The solution was to change my cPanel "Email Routing" option to "Remote" in order for all local emails to first check with the MX records.
add a comment |
The solution was to change my cPanel "Email Routing" option to "Remote" in order for all local emails to first check with the MX records.
add a comment |
The solution was to change my cPanel "Email Routing" option to "Remote" in order for all local emails to first check with the MX records.
The solution was to change my cPanel "Email Routing" option to "Remote" in order for all local emails to first check with the MX records.
answered Jan 4 at 14:24
mrg95mrg95
66712154
66712154
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54031724%2fmail-is-incorrectly-sending-emails-to-cpanel-default-account%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
We need more details, starting from code with mail sending.
– Oen44
Jan 4 at 0:38
It's a big script with support for email attachments and it works with any "to" address I give it. but sure, I'll edit.
– mrg95
Jan 4 at 0:39
2
Talk to your host. Chances are that they configured your domain for mail on that same server. Most MTAs will never even look at DNS if the domain exists locally.
– Sammitch
Jan 4 at 0:40
It's just to make sure that the script is correct to exclude possible cause of the problem.
– Oen44
Jan 4 at 0:41
4
Avoid using
mail()
in PHP anyway for many reasons. Ideally you should use a commercial-grade email gateway such as (and this is not an endorsment) SendGrid, which have a Web-service for sending email which is more reliable than PHP'smail()
or attempting to use SMTP directly from PHP. For example: sendgrid.com/docs/for-developers/sending-email/…– Dai
Jan 4 at 0:43