Search code examples
phpemailphpmailer

phpmailer - Is it possible to call message body using a specfied path to a html file?


I was wondering if there is a possibility to call the message body from a path specified instead of a php variable.
Instead of this,

$mail->Body=$body;

is there any way like specifying a path like this ('/mydomain/index.html')


Solution

  • Yes – just read the file yourself:

    $mail->Body = file_get_contents('/mydomain/index.html');