I am using CPanel with Apache, PHP and MySQL.
On the server there are many subdomains. The goal would be to be able to send emails from any subdomain, for instance, for the Forgot Password feature. There is a code which looks like this:
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->SetFrom('registrations@' . $domain_name, $domain_name . ' Registration System');
$mail->AddAddress($user->getEmail());
$mail->Subject = $label['password_remind_email_title'];
$mail->AltBody = $label['alternative_email_content']; // optional, comment out and test
$mail->MsgHTML($body);
$mail->Send();
This works well from the main domain, however, it does not send the email from subdomains. This is not an issue regarding missing email addresses, since I have been experimenting with hard-coding the main domain's email address, which exists for sure, and the behavior was the same, that is, the email was sent from the main domain and it was not sent from the subdomain.
If one faces an issue like this, what should be the steps to solve the issue (things to look at, things to do, things to make sure and so on)? Thanks.