Email Script to send Welcome Email to Non System Users

I aim to use the frappe.sendmail functionality, I read through this thread: Attachments with frappe.sendmail
to no avail. I did come up with this code, which does not work unfortunately. Basically I have a doctype called Secondary Sources. There is an email address in that form and I wish to send an email to that address each time a new Secondary Source document is created and saved. Here’s my code :

def sendmail():         
    content = "Test Content"
    recipient = self.email
    frappe.sendmail(recipients=[recipient],
        sender="xyz@gmail.com",
        subject="Test Subject", content=content)

I did not add this code in the .py file but rather created a server side script within ERPNext and added this code