I let PHPMailer do the heavy lifting:
      $email_addresses = array(
        'first.com'=>'j...@first.com'
        ,'another.com'=>'b...@another.com'
      );
      if (is_set($email_addresses[$returndomain])) $from_address = 
$email_addresses[$returndomain];
      else die("returndomain=$returndomain not in array");

      require_once(PHPMailer);
      $mail = new PHPMailer();
      $mail->IsMail();
      $mail->IsHTML(true);
      $mail->SetFrom($from_address);
      $mail->AddAddress($to_address, $to_name);
      $mail->Subject = "Order $order_item was rescheduled";
      $mail->Body = $html_body;
      $mail->AltBody = "Order $order_item was rescheduled.\n\n$body_2nd_line";
      $mail->Send();
$to_name is something like 'Mike Smith'. Leave it out if you don't have it.

HTH,
Bill

On 10/10/2017 3:23 PM, certified wrote:
How do I configure postfix to append the correct domain on outgoing emails
from php on apache:

I have LAMP on Centos 7 and a static IP. There are several domain names
registered to that static IP:
first.com -> my static ip
another.com -> my static ip
third.com -> my static ip
My postfix MX server is also on the webserver box.

php uses the following format:
$result = mail($to, $subject, $message, $headers, "-f returndomain")

So how do I configure postfix to append the correct domain on outgoing
emails:
if returndomain is first.com, I would like postfix to send it with the
virtual u...@first.com from addy
if returndomain is another.com, I would like postfix to send it with the
virtual u...@another.com from addy

Details:
1. I need to send confirmation emails using php on apache to people
registering for my services from the internet
2. I need to have the correct domain suffix and return path added to the
sender's email:
    j...@first.com sending from /var/www/html/first/ needs the email headers
all consistent with mail sent from first.com
    b...@another.com sending from  /var/www/html/another needs mail sent from
b...@another.com
3. these emails go TO pretty much anywhere - google, yahoo - anywhere
visitors request confirmation to go
4. these emails come FROM my MX on the webserver DIRECTLY to their email
addy, not relayed thru google etc.
5. the machine hostname isn't any of the above domain names, it is simply
somehost

Apache sends first.com requests to /var/www/html/first/ using DocumentRoot
"/var/www/html/first/"
Apache sends another.com requests to /var/www/html/first/ using DocumentRoot
"/var/www/html/another/"

obviously the user and group will be apache:apache

So how do I configure postfix to append the correct domain on outgoing
emails:
if returndomain is first.com, I would like postfix to send it with the
virtual u...@first.com from addy
if returndomain is another.com, I would like postfix to send it with the
virtual u...@another.com from addy

Note that I don't want to receive email on my MX.






--
Sent from: http://postfix.1071664.n5.nabble.com/Postfix-Users-f2.html

Reply via email to