send an encrypted email from my php script using python envelope

32 Views Asked by At

I can run the php script in the terminal but as soon as I want to run it through the browser it wont work. Hopefully someone can help me, thanks.

MK

Python script

#!/usr/bin/env python3
from envelope import Envelope

email_message = "Hello World"
EMAIL_FROM = "EMAIL"
email_address_recipient = "EMAIL"
file_path_attachment = "text.txt"
print(email_message)

e = (Envelope()
     .message(email_message)
     .from_(EMAIL_FROM)
     .to(email_address_recipient)
     .attach(path=file_path_attachment)
     .encryption()      
    )

e.as_message()  # returns EmailMessage

PHP Script

<?php

$check = shell_exec("python3 /var/www/vhosts/your-domain/httpdocs/test.py");

print_r($check);

?>

1

There are 1 best solutions below

0
user23458706 On

I found the problem. I needed to add the public keys as Webuser to my keyring