Send email in reply of any email not working












1














I have used below library to send email:



"illuminate/mail": "5.2.*"


My code to send email in reply of any email:



$sent = Mail::send(, , function ($msg) use ($data) {
$msg->from($data["from_address"], $data["from_name"])
->to($data["to_address"])->subject($data["subject"])->setBody($data["body"]);
if (isset($data["cc_address"])) {
$msg->cc($data["cc_address"]);
}
if (isset($data["bcc_address"])) {
$msg->bcc($data["bcc_address"]);
}
if (isset($data["attachment"])) {
foreach ($data["attachment"] as $attachment) {
$msg->attach($attachment['file'], $attachment['options']);
}
}
if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addCustomHeader("In-Reply-To", $data["message_id"]);
$msg->addCustomHeader("References", $data["message_id"]);
}
});


Here I have passed message id of email on which I want to send reply in header but it gives me error as below:



FatalErrorException in EmailCompose.php line 121:
Call to undefined method Swift_Mime_SimpleHeaderSet::addCustomHeader()


If I use method addTextHeader instead of addCustomHeader then it gives me below error:



ErrorException in Message.php line 296:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Swift_Message' does not have a method 'addTextHeader'


Please can you tell me how can I reply on any email?





as per suggestion I have change my code for below condition



if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]);
$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);
}


this code is allow me to send email but not in replay to the any email but it is sents email as new email



how to send email in replay to the any email.



please help me to resolve this issue , I will appreciate best answer.





I have found my solution,



change below,



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);


with



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"]." , ".$data["message_id"]);


and subject should be same as email on which you want to replay, only append "Re:" in the subject of email on which you want to reply



it resolve my issue



but another issue is how to get email body of previous emails in replay of email










share|improve this question
























  • do you mean reply ? this could help.. stackoverflow.com/questions/21633509/…
    – MuhittinCokelek
    Nov 22 '18 at 14:19












  • How about: $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]); $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["message_id"]);
    – Yahya Uddin
    Nov 22 '18 at 14:28










  • @YahyaUddin, let me check it separately
    – hetal gohel
    Nov 23 '18 at 4:02












  • @MuhittinCokelek , thanks , but it will not work for me
    – hetal gohel
    Nov 23 '18 at 4:03










  • hi @YahyaUddin , it is not sending email in repaly , it is send email as new email
    – hetal gohel
    Nov 23 '18 at 4:07
















1














I have used below library to send email:



"illuminate/mail": "5.2.*"


My code to send email in reply of any email:



$sent = Mail::send(, , function ($msg) use ($data) {
$msg->from($data["from_address"], $data["from_name"])
->to($data["to_address"])->subject($data["subject"])->setBody($data["body"]);
if (isset($data["cc_address"])) {
$msg->cc($data["cc_address"]);
}
if (isset($data["bcc_address"])) {
$msg->bcc($data["bcc_address"]);
}
if (isset($data["attachment"])) {
foreach ($data["attachment"] as $attachment) {
$msg->attach($attachment['file'], $attachment['options']);
}
}
if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addCustomHeader("In-Reply-To", $data["message_id"]);
$msg->addCustomHeader("References", $data["message_id"]);
}
});


Here I have passed message id of email on which I want to send reply in header but it gives me error as below:



FatalErrorException in EmailCompose.php line 121:
Call to undefined method Swift_Mime_SimpleHeaderSet::addCustomHeader()


If I use method addTextHeader instead of addCustomHeader then it gives me below error:



ErrorException in Message.php line 296:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Swift_Message' does not have a method 'addTextHeader'


Please can you tell me how can I reply on any email?





as per suggestion I have change my code for below condition



if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]);
$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);
}


this code is allow me to send email but not in replay to the any email but it is sents email as new email



how to send email in replay to the any email.



please help me to resolve this issue , I will appreciate best answer.





I have found my solution,



change below,



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);


with



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"]." , ".$data["message_id"]);


and subject should be same as email on which you want to replay, only append "Re:" in the subject of email on which you want to reply



it resolve my issue



but another issue is how to get email body of previous emails in replay of email










share|improve this question
























  • do you mean reply ? this could help.. stackoverflow.com/questions/21633509/…
    – MuhittinCokelek
    Nov 22 '18 at 14:19












  • How about: $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]); $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["message_id"]);
    – Yahya Uddin
    Nov 22 '18 at 14:28










  • @YahyaUddin, let me check it separately
    – hetal gohel
    Nov 23 '18 at 4:02












  • @MuhittinCokelek , thanks , but it will not work for me
    – hetal gohel
    Nov 23 '18 at 4:03










  • hi @YahyaUddin , it is not sending email in repaly , it is send email as new email
    – hetal gohel
    Nov 23 '18 at 4:07














1












1








1







I have used below library to send email:



"illuminate/mail": "5.2.*"


My code to send email in reply of any email:



$sent = Mail::send(, , function ($msg) use ($data) {
$msg->from($data["from_address"], $data["from_name"])
->to($data["to_address"])->subject($data["subject"])->setBody($data["body"]);
if (isset($data["cc_address"])) {
$msg->cc($data["cc_address"]);
}
if (isset($data["bcc_address"])) {
$msg->bcc($data["bcc_address"]);
}
if (isset($data["attachment"])) {
foreach ($data["attachment"] as $attachment) {
$msg->attach($attachment['file'], $attachment['options']);
}
}
if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addCustomHeader("In-Reply-To", $data["message_id"]);
$msg->addCustomHeader("References", $data["message_id"]);
}
});


Here I have passed message id of email on which I want to send reply in header but it gives me error as below:



FatalErrorException in EmailCompose.php line 121:
Call to undefined method Swift_Mime_SimpleHeaderSet::addCustomHeader()


If I use method addTextHeader instead of addCustomHeader then it gives me below error:



ErrorException in Message.php line 296:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Swift_Message' does not have a method 'addTextHeader'


Please can you tell me how can I reply on any email?





as per suggestion I have change my code for below condition



if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]);
$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);
}


this code is allow me to send email but not in replay to the any email but it is sents email as new email



how to send email in replay to the any email.



please help me to resolve this issue , I will appreciate best answer.





I have found my solution,



change below,



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);


with



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"]." , ".$data["message_id"]);


and subject should be same as email on which you want to replay, only append "Re:" in the subject of email on which you want to reply



it resolve my issue



but another issue is how to get email body of previous emails in replay of email










share|improve this question















I have used below library to send email:



"illuminate/mail": "5.2.*"


My code to send email in reply of any email:



$sent = Mail::send(, , function ($msg) use ($data) {
$msg->from($data["from_address"], $data["from_name"])
->to($data["to_address"])->subject($data["subject"])->setBody($data["body"]);
if (isset($data["cc_address"])) {
$msg->cc($data["cc_address"]);
}
if (isset($data["bcc_address"])) {
$msg->bcc($data["bcc_address"]);
}
if (isset($data["attachment"])) {
foreach ($data["attachment"] as $attachment) {
$msg->attach($attachment['file'], $attachment['options']);
}
}
if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addCustomHeader("In-Reply-To", $data["message_id"]);
$msg->addCustomHeader("References", $data["message_id"]);
}
});


Here I have passed message id of email on which I want to send reply in header but it gives me error as below:



FatalErrorException in EmailCompose.php line 121:
Call to undefined method Swift_Mime_SimpleHeaderSet::addCustomHeader()


If I use method addTextHeader instead of addCustomHeader then it gives me below error:



ErrorException in Message.php line 296:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Swift_Message' does not have a method 'addTextHeader'


Please can you tell me how can I reply on any email?





as per suggestion I have change my code for below condition



if (isset($data["message_id"])) {
$msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]);
$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);
}


this code is allow me to send email but not in replay to the any email but it is sents email as new email



how to send email in replay to the any email.



please help me to resolve this issue , I will appreciate best answer.





I have found my solution,



change below,



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"].$data["message_id"]);


with



$msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["referances"]." , ".$data["message_id"]);


and subject should be same as email on which you want to replay, only append "Re:" in the subject of email on which you want to reply



it resolve my issue



but another issue is how to get email body of previous emails in replay of email







laravel email lumen swiftmailer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 8:00

























asked Nov 22 '18 at 13:32









hetal gohel

1079




1079












  • do you mean reply ? this could help.. stackoverflow.com/questions/21633509/…
    – MuhittinCokelek
    Nov 22 '18 at 14:19












  • How about: $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]); $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["message_id"]);
    – Yahya Uddin
    Nov 22 '18 at 14:28










  • @YahyaUddin, let me check it separately
    – hetal gohel
    Nov 23 '18 at 4:02












  • @MuhittinCokelek , thanks , but it will not work for me
    – hetal gohel
    Nov 23 '18 at 4:03










  • hi @YahyaUddin , it is not sending email in repaly , it is send email as new email
    – hetal gohel
    Nov 23 '18 at 4:07


















  • do you mean reply ? this could help.. stackoverflow.com/questions/21633509/…
    – MuhittinCokelek
    Nov 22 '18 at 14:19












  • How about: $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]); $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["message_id"]);
    – Yahya Uddin
    Nov 22 '18 at 14:28










  • @YahyaUddin, let me check it separately
    – hetal gohel
    Nov 23 '18 at 4:02












  • @MuhittinCokelek , thanks , but it will not work for me
    – hetal gohel
    Nov 23 '18 at 4:03










  • hi @YahyaUddin , it is not sending email in repaly , it is send email as new email
    – hetal gohel
    Nov 23 '18 at 4:07
















do you mean reply ? this could help.. stackoverflow.com/questions/21633509/…
– MuhittinCokelek
Nov 22 '18 at 14:19






do you mean reply ? this could help.. stackoverflow.com/questions/21633509/…
– MuhittinCokelek
Nov 22 '18 at 14:19














How about: $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]); $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["message_id"]);
– Yahya Uddin
Nov 22 '18 at 14:28




How about: $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", $data["message_id"]); $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", $data["message_id"]);
– Yahya Uddin
Nov 22 '18 at 14:28












@YahyaUddin, let me check it separately
– hetal gohel
Nov 23 '18 at 4:02






@YahyaUddin, let me check it separately
– hetal gohel
Nov 23 '18 at 4:02














@MuhittinCokelek , thanks , but it will not work for me
– hetal gohel
Nov 23 '18 at 4:03




@MuhittinCokelek , thanks , but it will not work for me
– hetal gohel
Nov 23 '18 at 4:03












hi @YahyaUddin , it is not sending email in repaly , it is send email as new email
– hetal gohel
Nov 23 '18 at 4:07




hi @YahyaUddin , it is not sending email in repaly , it is send email as new email
– hetal gohel
Nov 23 '18 at 4:07

















active

oldest

votes











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432141%2fsend-email-in-reply-of-any-email-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


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




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432141%2fsend-email-in-reply-of-any-email-not-working%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo