• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

Question How to control smtp.mailfrom in mails sent from Plesk?

Kroptokin

Regular Pleskian
Server operating system version
AlmaLinux 9.6 (Sage Margay)
Plesk version and microupdate number
Plesk Obsidian 18.0.70 Update #1 Web Host Edition
I am sending mail from a Plesk Server using PHPMailer.

I have several domains on this server. I am connecting to the mail server with this code:

$mail->Host = 'localhost';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'b';
$mail->SMTPSecure = '';
$mail->Port = 25;
$mail->Sender = '[email protected]';
$mail->setFrom('[email protected]');

Username is an email account on one domain.

In the emails I see this:

Authentication-Results: spf=pass (sender IP is 77.68.123.62)
smtp.mailfrom=domain2.com; dkim=fail (no key for signature)

domain2.com is indeed hosted on the same server. But I want this field to be domain1. I thought it might be to do with using Sender in PHPMailer. But no.

It looks to me like it could be something I need to fix in Plesk.

Does anybody have any ideas?
 
I do not believe that is a plesk issue but probably how you implemented PHPMailer. Looking over the doc over GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP shows me that the initial configs should be as follow (mind you this is based off of the latest version):

PHP:
    $mail->isSMTP();                                            //Send using SMTP
    $mail->Host       = 'smtp.example.com';                     //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
    $mail->Username   = '[email protected]';                     //SMTP username
    $mail->Password   = 'secret';                               //SMTP password
    $mail->Port       = 25;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

    //Recipients
    $mail->setFrom('[email protected]', 'From Name');
    $mail->addReplyTo('[email protected]', 'From Name');

Alternatively you could just use Sendmail (built in PHP function).

PHP:
$mail->isSendmail();
$mail->setFrom('[email protected]', 'From Name');
$mail->addReplyTo('[email protected]', 'From Name);

But I'm not tooooo familiar with PHP (I just use whatever is out there lol) but ye in either case, I'd double check how you've implemented it.
 
thanks @scsa20 - to be honest, I already have something like this using PHPMailer, and I already tried mail() (that was why I switched to PHPMailer). I need to solve this problem, so I will keep looking. When I find the result I will post it back here.
 
OK. Thanks again and sorry. It turns out the mailfrom header was being set because I was forwarding the emails. domain1 => [email protected] => a personal email. Once I send the emails directly from Plesk, using the above code, with no forwarding step I see smtp.mailfrom=domain1.com
 
Back
Top