Frappe.sendmail vs communication.email.make

Hi there. I tried two methods for sending email in ERPNext. I had to add both the recipients and CC while sending the email. But while using frappe.sendmail() method, CC is shown as “To”.


while using make() function “frappe.core.doctype.communication.email” is working correctly.


Can anyone identify what’s the issue? Because I have seen that frappe.sendmail function is already used in many places in the code.

Kind Regards

Share your full code

If frappe.sendmail() works for you, why don’t you use it instead of make()?

Do you know what are the advantage/disadvatage of each method?

As mentioned in the question, when I use frappe.sendmail() and include a CC, the CC is shown as “To” in the email (the email received by CC account). See this picture, it is the one received by CC account

But it works correctly when I use make() function. Following is the received email by CC account

And @rahy no i dont have much knowledge about the advantage/disadvantage of each method i just tried the make() method and it solved my prob, if you could please guide the recommended approach it will be appreciated.

1 Like

Hi @Ammar-Ahmad-Khan, could you share the make() method code.

Hello @Ammar-Ahmad-Khan I also had that issue myself. but I tried using the make() but it still didn’t work for me so I added
expose_recipients= ‘header’,
to the frappe.sendmail.
the code should be written like this:
frappe.sendmail(
recipients=recipients,
cc=cc,
subject=(“HAPPY BIRTHDAY”),
template=“birthday_reminder”,
expose_recipients= ‘header’,
args=dict(
reminder_text=reminder_text,
birthday_persons=birthday_persons,
message=message,
),
header=
(“HAPPY BIRTHDAY!!! :birthday:”),
)

I observed that,

  • With make() is that it adds the communication to the timeline of the document.

  • Whereas, sendmail() does not have any records anywhere other than Email Queue List.

And, if I’m not mistaken:

  • make() will put the email in jobs queue.
  • sendmail() will send immediately.
1 Like