title: Set origin IP in PHPmailer
body: <p>I wanted to rotate the origin IP addresses in an email script, it is used to send notifications to my customers.</p>
  
  <p>My server comes with 5  ip addresses, so I created an array of IPs and while sending the IP address changed randomly, in this array I do not include the main server IP.</p>
  
  <p>This was working fine until last december, I have not made any change nor update (I am not sure if there was any automatic)</p>
  
  <p>Here is the script:</p>
  
  <pre><code> $iparray = array(
      '163.xx.217.xx',
      '164.xx.217.xx',
  );
  
  $ips = $iparray;
  $keyip = array_rand($ips);
  
  
  
          $mail = new PHPMailer();
          $mail-&gt;IsSMTP(); 
          $mail-&gt;CharSet = 'UTF-8';
          $mail-&gt;SMTPDebug  = 0;                     
          $mail-&gt;SMTPAuth   = true;                  
          $mail-&gt;SMTPSecure = "none";               
          $mail-&gt;Host       = $ips[$keyip];      
          $mail-&gt;Port       = 26;             
          $mail-&gt;AddAddress($recipient);
          $mail-&gt;Username=$senderemail;  
          $mail-&gt;Password=$senderpass;            
          $mail-&gt;SetFrom($senderemail,$sendername);
          $mail-&gt;AddReplyTo($senderemail,$sendername);
          $mail-&gt;AddBCC('smtp@xxxxx.co');
          $mail-&gt;Subject    = 'the subject';
          $mail-&gt;MsgHTML('the message);
  </code></pre>
  
  <p>Note that $mail->Host was an IP randomly selected from the array, when checking on the message received, I used to get this:</p>
  
  <pre><code>spf=pass (google.com: domain of test@xxxxxxx.co designates 163.xx.217.xx as permitted sender) smtp.mailfrom=test@xxxxxxx.co
  </code></pre>
  
  <p>However, since December, the SPF check is being made on the server main IP, instead of any of the selected IP in the array, which I do not want.</p>
  
  <p>This was working properly but all of the sudden it changed, could it be Gmail servers? Could it be something to be configured in the server?</p>
  
  <p>In order to send emails, I  use Exim, installed on a Centos server, managed via WHM.</p>
  
  <p>I am not trying to spoof any address, all IP addresses are mine, I just need to make sure they rotate on every email sent, and I could do it but now I am not sure what to change to make it work again.</p>
  
  <p>Thanks for all your help</p>