Skip to content
Advertisement

Using global variables in PHPMailer

Instead of this:

JavaScript

I would like to keep the values in a separate file and use variables instead:

JavaScript

I’m already using output buffering, have set the global scope, and the variable values contain the quotes. Still not working.

Advertisement

Answer

To begin with, kindly read @Synchro‘s comment.

  • Create a php file if you’ve not done that already (eg. mail_config.php) and declare your variables in it.
  • Require/Include the mail_config.php file in your “main” file (the file that will send the mail eg. send_mail.php).
  • Assign the PHPMailer props to their respective variables from the mail_config.php file in the send_mail.php file.

Example

mail_config.php

JavaScript

send_mail.php

JavaScript

Read more https://github.com/PHPMailer/PHPMailer

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement