How to change email sender email in PHP Mailer
Currentlt it shows the mail on which phpmailer SMTP is registered.
$email='abc@email.com';
$subjectRsc="Any";
$message='Welcome';
phpmail($email, $subjectRsc, $message);
My phpmailer function:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->AddReplyTo(REPLY_EMAIL, 'ABC');
$mail->SetFrom(FROM_EMAIL, 'ABC');
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
This is how I am sending mails to the users I want to show the specific mail of my website to be displayed in the mails not that on which smtp server is registered.
php smtp phpmailer
|
show 2 more comments
Currentlt it shows the mail on which phpmailer SMTP is registered.
$email='abc@email.com';
$subjectRsc="Any";
$message='Welcome';
phpmail($email, $subjectRsc, $message);
My phpmailer function:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->AddReplyTo(REPLY_EMAIL, 'ABC');
$mail->SetFrom(FROM_EMAIL, 'ABC');
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
This is how I am sending mails to the users I want to show the specific mail of my website to be displayed in the mails not that on which smtp server is registered.
php smtp phpmailer
Possible duplicate of PHP E-mail Form Sender Name Instead Of E-mail?
– Farkie
Nov 15 '18 at 8:27
Please include defitinition of functionphpmail()as there is no such built-in php function. Are you using php.net/manual/en/function.mail.php internally? Or are you using some library such as PHPMailer?
– Kyborek
Nov 15 '18 at 8:27
Possible duplicate of phpmailer change mail sender
– Oleg Nurutdinov
Nov 15 '18 at 8:28
Are you using the library: PHPMailer or Php's mail function 'mail', I can't find a reference for a function named: 'phpmail' that you have as your code sample. Confused.
– Progrock
Nov 15 '18 at 8:45
I am using phpmailer library
– Shahzaib
Nov 15 '18 at 8:57
|
show 2 more comments
Currentlt it shows the mail on which phpmailer SMTP is registered.
$email='abc@email.com';
$subjectRsc="Any";
$message='Welcome';
phpmail($email, $subjectRsc, $message);
My phpmailer function:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->AddReplyTo(REPLY_EMAIL, 'ABC');
$mail->SetFrom(FROM_EMAIL, 'ABC');
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
This is how I am sending mails to the users I want to show the specific mail of my website to be displayed in the mails not that on which smtp server is registered.
php smtp phpmailer
Currentlt it shows the mail on which phpmailer SMTP is registered.
$email='abc@email.com';
$subjectRsc="Any";
$message='Welcome';
phpmail($email, $subjectRsc, $message);
My phpmailer function:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->AddReplyTo(REPLY_EMAIL, 'ABC');
$mail->SetFrom(FROM_EMAIL, 'ABC');
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
This is how I am sending mails to the users I want to show the specific mail of my website to be displayed in the mails not that on which smtp server is registered.
php smtp phpmailer
php smtp phpmailer
edited Nov 15 '18 at 9:19
Shahzaib
asked Nov 15 '18 at 8:24
ShahzaibShahzaib
89
89
Possible duplicate of PHP E-mail Form Sender Name Instead Of E-mail?
– Farkie
Nov 15 '18 at 8:27
Please include defitinition of functionphpmail()as there is no such built-in php function. Are you using php.net/manual/en/function.mail.php internally? Or are you using some library such as PHPMailer?
– Kyborek
Nov 15 '18 at 8:27
Possible duplicate of phpmailer change mail sender
– Oleg Nurutdinov
Nov 15 '18 at 8:28
Are you using the library: PHPMailer or Php's mail function 'mail', I can't find a reference for a function named: 'phpmail' that you have as your code sample. Confused.
– Progrock
Nov 15 '18 at 8:45
I am using phpmailer library
– Shahzaib
Nov 15 '18 at 8:57
|
show 2 more comments
Possible duplicate of PHP E-mail Form Sender Name Instead Of E-mail?
– Farkie
Nov 15 '18 at 8:27
Please include defitinition of functionphpmail()as there is no such built-in php function. Are you using php.net/manual/en/function.mail.php internally? Or are you using some library such as PHPMailer?
– Kyborek
Nov 15 '18 at 8:27
Possible duplicate of phpmailer change mail sender
– Oleg Nurutdinov
Nov 15 '18 at 8:28
Are you using the library: PHPMailer or Php's mail function 'mail', I can't find a reference for a function named: 'phpmail' that you have as your code sample. Confused.
– Progrock
Nov 15 '18 at 8:45
I am using phpmailer library
– Shahzaib
Nov 15 '18 at 8:57
Possible duplicate of PHP E-mail Form Sender Name Instead Of E-mail?
– Farkie
Nov 15 '18 at 8:27
Possible duplicate of PHP E-mail Form Sender Name Instead Of E-mail?
– Farkie
Nov 15 '18 at 8:27
Please include defitinition of function
phpmail() as there is no such built-in php function. Are you using php.net/manual/en/function.mail.php internally? Or are you using some library such as PHPMailer?– Kyborek
Nov 15 '18 at 8:27
Please include defitinition of function
phpmail() as there is no such built-in php function. Are you using php.net/manual/en/function.mail.php internally? Or are you using some library such as PHPMailer?– Kyborek
Nov 15 '18 at 8:27
Possible duplicate of phpmailer change mail sender
– Oleg Nurutdinov
Nov 15 '18 at 8:28
Possible duplicate of phpmailer change mail sender
– Oleg Nurutdinov
Nov 15 '18 at 8:28
Are you using the library: PHPMailer or Php's mail function 'mail', I can't find a reference for a function named: 'phpmail' that you have as your code sample. Confused.
– Progrock
Nov 15 '18 at 8:45
Are you using the library: PHPMailer or Php's mail function 'mail', I can't find a reference for a function named: 'phpmail' that you have as your code sample. Confused.
– Progrock
Nov 15 '18 at 8:45
I am using phpmailer library
– Shahzaib
Nov 15 '18 at 8:57
I am using phpmailer library
– Shahzaib
Nov 15 '18 at 8:57
|
show 2 more comments
3 Answers
3
active
oldest
votes
You should try this :
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->addReplyTo('myemail@example.com', 'ABC'); //<-- this is the line i changed
$mail->From= "myemail@example.com"; //<-- this is the line i changed
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
According to phpmailer documentation this is the field to add the sender's email.
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with$mail->send();where in $mail is your array with all the info to be send.
– pr1nc3
Nov 15 '18 at 8:58
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
|
show 3 more comments
please try using this code :
<?php
require_once "vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from@yourdomain.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("test@gmail.com", "Test");
$mail->addAddress("test1@gmail.com");
//Address to which recipient will reply
//if you want to add CC and BCC
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
add a comment |
Please try using this code:
<?php
$to = "test@gmail.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:test1@gmail.com rn";
$header .= "Cc:test2@gmail rn";
$header .= "MIME-Version: 1.0rn";
$header .= "Content-type: text/htmlrn";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
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%2f53315115%2fhow-to-change-email-sender-email-in-php-mailer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should try this :
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->addReplyTo('myemail@example.com', 'ABC'); //<-- this is the line i changed
$mail->From= "myemail@example.com"; //<-- this is the line i changed
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
According to phpmailer documentation this is the field to add the sender's email.
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with$mail->send();where in $mail is your array with all the info to be send.
– pr1nc3
Nov 15 '18 at 8:58
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
|
show 3 more comments
You should try this :
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->addReplyTo('myemail@example.com', 'ABC'); //<-- this is the line i changed
$mail->From= "myemail@example.com"; //<-- this is the line i changed
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
According to phpmailer documentation this is the field to add the sender's email.
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with$mail->send();where in $mail is your array with all the info to be send.
– pr1nc3
Nov 15 '18 at 8:58
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
|
show 3 more comments
You should try this :
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->addReplyTo('myemail@example.com', 'ABC'); //<-- this is the line i changed
$mail->From= "myemail@example.com"; //<-- this is the line i changed
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
According to phpmailer documentation this is the field to add the sender's email.
You should try this :
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Debugoutput = 'html';
$mail->Host = 'smptp';
$mail->Port = 465; // or 587
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->SMTPAuth = true;
$mail->Username = PHP_MAILER_EMAIL;
$mail->Password = PHP_MAILER_PASSWORD;
$mail->addReplyTo('myemail@example.com', 'ABC'); //<-- this is the line i changed
$mail->From= "myemail@example.com"; //<-- this is the line i changed
$mail->Subject = $subject;
$address = $to;
$mail->AddAddress($address);
$mail->MsgHTML($message);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
According to phpmailer documentation this is the field to add the sender's email.
edited Nov 15 '18 at 9:53
answered Nov 15 '18 at 8:28
pr1nc3pr1nc3
4,2192723
4,2192723
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with$mail->send();where in $mail is your array with all the info to be send.
– pr1nc3
Nov 15 '18 at 8:58
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
|
show 3 more comments
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with$mail->send();where in $mail is your array with all the info to be send.
– pr1nc3
Nov 15 '18 at 8:58
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
I am not using mail function, I am using php mailer phpmail function
– Shahzaib
Nov 15 '18 at 8:57
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with
$mail->send(); where in $mail is your array with all the info to be send.– pr1nc3
Nov 15 '18 at 8:58
phpmail function is not user in phpmailer library. Is it a custom function you created? phpmailer send email with
$mail->send(); where in $mail is your array with all the info to be send.– pr1nc3
Nov 15 '18 at 8:58
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
yes you are right
– Shahzaib
Nov 15 '18 at 9:10
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
Then can you provide your phpmail function? The problem you are trying to solve is there. Just edit your question.
– pr1nc3
Nov 15 '18 at 9:11
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
I have edited my question check now
– Shahzaib
Nov 15 '18 at 9:20
|
show 3 more comments
please try using this code :
<?php
require_once "vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from@yourdomain.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("test@gmail.com", "Test");
$mail->addAddress("test1@gmail.com");
//Address to which recipient will reply
//if you want to add CC and BCC
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
add a comment |
please try using this code :
<?php
require_once "vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from@yourdomain.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("test@gmail.com", "Test");
$mail->addAddress("test1@gmail.com");
//Address to which recipient will reply
//if you want to add CC and BCC
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
add a comment |
please try using this code :
<?php
require_once "vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from@yourdomain.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("test@gmail.com", "Test");
$mail->addAddress("test1@gmail.com");
//Address to which recipient will reply
//if you want to add CC and BCC
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
please try using this code :
<?php
require_once "vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from@yourdomain.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("test@gmail.com", "Test");
$mail->addAddress("test1@gmail.com");
//Address to which recipient will reply
//if you want to add CC and BCC
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
answered Nov 15 '18 at 10:12
Atul AkabariAtul Akabari
954
954
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
add a comment |
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
not working only FromName is working
– Shahzaib
Nov 15 '18 at 10:48
add a comment |
Please try using this code:
<?php
$to = "test@gmail.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:test1@gmail.com rn";
$header .= "Cc:test2@gmail rn";
$header .= "MIME-Version: 1.0rn";
$header .= "Content-type: text/htmlrn";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
add a comment |
Please try using this code:
<?php
$to = "test@gmail.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:test1@gmail.com rn";
$header .= "Cc:test2@gmail rn";
$header .= "MIME-Version: 1.0rn";
$header .= "Content-type: text/htmlrn";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
add a comment |
Please try using this code:
<?php
$to = "test@gmail.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:test1@gmail.com rn";
$header .= "Cc:test2@gmail rn";
$header .= "MIME-Version: 1.0rn";
$header .= "Content-type: text/htmlrn";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
Please try using this code:
<?php
$to = "test@gmail.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:test1@gmail.com rn";
$header .= "Cc:test2@gmail rn";
$header .= "MIME-Version: 1.0rn";
$header .= "Content-type: text/htmlrn";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
edited Dec 19 '18 at 8:54
bfontaine
9,20874373
9,20874373
answered Nov 15 '18 at 11:18
Atul AkabariAtul Akabari
954
954
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
add a comment |
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
I achieve this by changing my smtp email
– Shahzaib
Dec 19 '18 at 7:59
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%2f53315115%2fhow-to-change-email-sender-email-in-php-mailer%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
Possible duplicate of PHP E-mail Form Sender Name Instead Of E-mail?
– Farkie
Nov 15 '18 at 8:27
Please include defitinition of function
phpmail()as there is no such built-in php function. Are you using php.net/manual/en/function.mail.php internally? Or are you using some library such as PHPMailer?– Kyborek
Nov 15 '18 at 8:27
Possible duplicate of phpmailer change mail sender
– Oleg Nurutdinov
Nov 15 '18 at 8:28
Are you using the library: PHPMailer or Php's mail function 'mail', I can't find a reference for a function named: 'phpmail' that you have as your code sample. Confused.
– Progrock
Nov 15 '18 at 8:45
I am using phpmailer library
– Shahzaib
Nov 15 '18 at 8:57