title: PHP Mailer Class - Securing Email Credentials
body: <p>I am using the php mailer class to send email via my scripts.</p>
  
  <p>The structure is as follows:</p>
  
  <p>$mail = new PHPMailer;</p>
  
  <pre><code>$mail-&gt;IsSMTP();                                      // Set mailer to use SMTP
  $mail-&gt;Host = 'myserver.com';  // Specify main and backup server
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  $mail-&gt;Username = 'info@somedomain.com';                            // SMTP username
  $mail-&gt;Password = 'user123';                           // SMTP password
  $mail-&gt;SMTPSecure = 'pass123';  
  </code></pre>
  
  <p>It seems to me to be a bit of a security hole having the mailbox credentials in plain view. So I thought I might put these in an external file outside of the web root. My question is how would I then assign the $mail object these values.</p>
  
  <p>I of course no how to use <code>include</code> and/or <code>requires</code>... would it simple be a case of....</p>
  
  <pre><code>$mail-&gt;IsSMTP();                                      // Set mailer to use SMTP
  $mail-&gt;Host = 'myserver.com';  // Specify main and backup server
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  
  includes '../locationOutsideWebroot/emailCredntials.php';
  
  $mail-&gt;SMTPSecure = 'pass123';
  </code></pre>
  
  <p>Then emailCredentails.php:</p>
  
  <pre><code>&lt;?php
  $mail-&gt;Username = 'info@somedomain.com';
  $mail-&gt;Password = 'user123';
  ?&gt;
  </code></pre>
  
  <p>Would this be sufficient and secure enough?</p>
  
  <p>Thanks,</p>
  
  <p>Alan.</p>