• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Issue Migrated using "temporary" domain name - can't get server to send PHP emails from "main" domain name

trippy

New Pleskian
Server operating system version
Ubuntu 24.04.3 LTS
Plesk version and microupdate number
Plesk Obsidian 18.0.71 Update #2
Not sure how to phrase this and therefore turning up nothing in searches.

My plesk powered root server hosts an existing site I was hosting elsewhere. To prep for migration I set up mydomain.me on the plesk server, staged up all my web files, etc. and then on moving day I shut off the older server and redirected mydomain.com there as well.

Now, the .me domain forward to the .com domain and my production site runs on .com

but since I set up .me in the beginning all emails generated by the .com website which runs PHP come FROM .me and fail DKIM and other validations. because while the server sends it from .me the email's "from" address is actually .com

Is there any way to fix this?
 
[...]
Is there any way to fix this?
I am assume you're referring to emails send from your website, like a contact or order form. In that case the solution is quite simple, configure your website form(s) to use the new domain. This is likely something you can edit in some where your CMS or in the website code.

But if you are not sure where to change the sender address of your website, the article @scsa20 linked to will help you force a particular address to be used by PHP. That will only work if your website uses PHP of course.
 
I'm not sure what you're trying to say in terms of the server moves and such but if you're trying to make it so emails sent using the PHP mail() function, you can follow the guide for one domain over at https://support.plesk.com/hc/en-us/...n-are-rejected-on-some-recipient-mail-servers which shows you how to make it so it'll send emails as [email protected] instead of [email protected].
Thank you, I will look at that.
I am assume you're referring to emails send from your website, like a contact or order form. In that case the solution is quite simple, configure your website form(s) to use the new domain. This is likely something you can edit in some where your CMS or in the website code.

But if you are not sure where to change the sender address of your website, the article @scsa20 linked to will help you force a particular address to be used by PHP. That will only work if your website uses PHP of course.
My website is 20 years old and has used the .com domain all that time. I used the .me domain only to stage the site for the server migration. Now that it's done, I want my emails from the site to be from .com

For more mission critical emails, we use a third party service to send emails - those are working fine of course. But for lower priority notices, we prefer to send the emails from our web app (PHP) to save the money. We want those to go out as from .com emails

They are - but the SERVER is attaching d=mydomain.me to the email header when sending. Causing the emails to trigger DKIM failures everywhere.

I cannot seem to configure the server to use the .COM address there and I'm assuming it's because when I staged up my server I used the .me as the main domain in the "subscriptions" listing.

I'll read the guide linked, but in case it helps this is the DMARC report result I'm trying to address. Right now it only shows 35 because as a stop-gap I have almost all my email going through the third party. Okay for now, but $$ is adding up and I need to revert to my old method long term.

<record>
<row>
<source_ip>XX.XX.XX.XX</source_ip>
<count>35</count>
<policy_evaluated>
<disposition>none</disposition>
<dkim>fail</dkim>
<spf>pass</spf>
</policy_evaluated>
</row>
<identifiers>
<header_from>mysite.com</header_from>
</identifiers>
<auth_results>
<dkim>
<domain>mysite.me</domain>
<result>fail</result>
<selector>default</selector>
</dkim>
<spf>
<domain>mysite.com</domain>
<result>pass</result>
</spf>
</auth_results>
</record>

I don't seem to have control over the DKIM part of this. That appears to me to be done down at a server level. I think down as the postfix level and for the life of me I can't seem to change it. I suspect it's because when I was staging everything I put in the subscription as mysite.me and it just "stuck" and that's what gets funneled down somehow to postfix. But I'm not a guru on this stuff and I'm out of my depth which is why I'm asking for any ideas or help. Appreciate anything.
 
Gotcha now. Just so I understand your current setup, are you hosting the .com domain on your Plesk server too? If so, how did you add the domains to Plesk? Is the .me domain the webspace (subscription) domain and the .com just an alias of the .me domain?
 
the .me is the subscription
the .com is a domain under that subscription. Here is what I see:
I click the hosting settings under .com and it says "hosting type: website"
It goes to a document root where the files are

I don't believe it is an alias.

I had to do this to get my .com email addresses to work.
I had to set it up this way to create my [email protected] emails. Which all work and I can use them via webmail or a client.

I did a test earlier and emailed my gmail account using one of the .com domain emails from webmail - and the headers all looked fine.

In my PHP code I do this:

$envelopeSender = $this->from ?: '[email protected]';
ini_set('sendmail_path', "/usr/sbin/sendmail -t -i -f$envelopeSender");
$success = @mail($this->to, $this->subject, $this->body, $this->headers);

This was my attempt to force this at the PHP level but it does not seem to work.

Appreciate the reply, thank you
 
Understood. By default the subscription domain is used as the SMTP/envelope sender if no other address has been configured. Since your .com domain is in the .me subscription, that's what your seeing too.

The reason your test code doesn't work is because the sendmail_path cannot be set using ini_set. You'll either have to add the sendmail_path as an additional PHP directive (as described in the Plesk support article) or set it as the fifth parameter of the mail() function. For example:
PHP:
$envelopeSender = '[email protected]';
$success = @mail($this->to, $this->subject, $this->body, $this->headers, "-f$envelopeSender");

Both methods should accomplish what your after.
 
I'll try the -f but I attempted that previously with no effect. What I posted is a subsequent attempt, but what my current code is. I will test your -f suggestion though and post an update.

Thank you again for the suggestions. I will post an update.
 
Back
Top