We support processing over email. You can send a PDF to our designated email address via attachments and we will process it as if you uploaded it via the API.
Your users email must match the sender
For us to securely process your documents, we need to verify that the email is sent from your users. So please make sure that your Areal user's email matches the sender of the email.
Attachments is all you need
We only care about the attachments in the email. Body will be ignored.
Your email body will be ignored.
importsmtplibimportsslfromemailimportencodersfromemail.mime.baseimportMIMEBasefromemail.mime.multipartimportMIMEMultipartfromemail.mime.textimportMIMETextfrompathlibimportPathfromtypingimportList,Optionaldefsend_email(receiver_email:str,subject:str,body:str,attachment_paths:Optional[List[str]]=None,sender_email:str="your_email@example.com",smtp_server:str="smtp.gmail.com",smtp_port:int=587,password:str="your_app_password",)->bool:try:# Create the email messagemessage=MIMEMultipart()message["From"]=sender_emailmessage["To"]=receiver_emailmessage["Subject"]=subject# Add body to emailmessage.attach(MIMEText(body,"plain"))# Process attachments if anyifattachment_paths:forattachment_pathinattachment_paths:try:withopen(attachment_path,"rb")asattachment:# Create the attachment partpart=MIMEBase("application","octet-stream")part.set_payload(attachment.read())# Encode the attachmentencoders.encode_base64(part)# Add header to attachmentfilename=Path(attachment_path).namepart.add_header("Content-Disposition",f"attachment; filename= {filename}")# Add attachment to messagemessage.attach(part)exceptExceptionase:print(f"Error processing attachment {attachment_path}: {str(e)}")continue# Create secure SSL/TLS contextcontext=ssl.create_default_context()# Connect to the SMTP server and send emailwithsmtplib.SMTP(smtp_server,smtp_port)asserver:server.starttls(context=context)server.login(sender_email,password)server.send_message(message)returnTrueexceptExceptionase:print(f"Error sending email: {str(e)}")returnFalse
importjava.util.*;importjava.util.Properties;importjavax.mail.*;importjavax.mail.internet.*;importjava.io.File;importjava.io.FileInputStream;importjava.io.IOException;publicclassProcessingOverEmail{publicstaticbooleansendEmail(StringreceiverEmail,Stringsubject,Stringbody,List<String>attachmentPaths,StringsenderEmail,StringsmtpServer,intsmtpPort,Stringpassword){try{// Create the email messagePropertiesproperties=newProperties();properties.put("mail.smtp.host",smtpServer);properties.put("mail.smtp.port",String.valueOf(smtpPort));properties.put("mail.smtp.auth","true");properties.put("mail.smtp.starttls.enable","true");Sessionsession=Session.getInstance(properties,newAuthenticator(){@OverrideprotectedPasswordAuthenticationgetPasswordAuthentication(){returnnewPasswordAuthentication(senderEmail,password);}});Messagemessage=newMimeMessage(session);message.setFrom(newInternetAddress(senderEmail));message.setRecipient(Message.RecipientType.TO,newInternetAddress(receiverEmail));message.setSubject(subject);// Create multipart messageMultipartmultipart=newMimeMultipart();// Add body to emailMimeBodyParttextPart=newMimeBodyPart();textPart.setText(body);multipart.addBodyPart(textPart);// Process attachments if anyif(attachmentPaths!=null){for(StringattachmentPath:attachmentPaths){try{MimeBodyPartattachmentPart=newMimeBodyPart();Filefile=newFile(attachmentPath);attachmentPart.attachFile(file);multipart.addBodyPart(attachmentPart);}catch(IOExceptione){System.out.println("Error processing attachment "+attachmentPath+": "+e.getMessage());continue;}}}message.setContent(multipart);// Send emailTransport.send(message);returntrue;}catch(MessagingExceptione){System.out.println("Error sending email: "+e.getMessage());returnfalse;}}publicstaticvoidmain(String[]args){List<String>attachments=Arrays.asList("sample.pdf");sendEmail("receiver@example.com","Subject","Body",attachments,"your_email@example.com","smtp.gmail.com",587,"your_app_password");}}