title: Sending emails with PHPMailer
body: <p>I'm struggling to understand how to send emails with PHPMailer.</p>
  
  <p>I have multiple website clients and I have implemented a contact form for each of them. I can send emails to my own email address but not to theirs.</p>
  
  <p>This is the function I wrote to do it.</p>
  
  <pre><code>function sendSMTP($host, $usr, $pwd, $port, $fromAddr, $fromName, 
  $replyAddr, $replyName, $addr, $subject, $body)
  {
  $mail = new PHPMailer(true);
  
  $mail-&gt;SMTPDebug  = 1; 
  
  $mail-&gt;isSMTP();
  $mail-&gt;Host         = $host;
  $mail-&gt;SMTPAuth     = true;
  $mail-&gt;Username     = $usr;
  $mail-&gt;Password     = $pwd;
  $mail-&gt;SMTPSecure   = 'ssl';
  $mail-&gt;Port         = $port;
  
  $mail-&gt;setFrom($fromAddr, $fromName);
  $mail-&gt;addReplyTo($replyAddr, $replyName);
  
  $mail-&gt;addAddress($addr);
  
  $mail-&gt;isHTML(true);
  
  $mail-&gt;Subject = $subject;
  $mail-&gt;Body    = $body;
  }
  </code></pre>
  
  <p>I have a feeling it's not working because of something to do with the first 4 parameters (host, user, password, port). I started this months ago and sat on it and now I'm totally lost on how to fix it.</p>
  
  <p>Do I have to authenticate various sender accounts for each client? I'm stuck. What is the correct way to use this function?</p>