Skip to content Skip to sidebar Skip to footer

Email And Web Split On Different Servers: Send Email Via Php To An Email On That Domain

1 Domain that has port80 and MX split on the DNS: Website is hosted on a VPS. Email is hosted on a shared host. When I call the mail() function in PHP on the website that is addr

Solution 1:

Drop the mail() function in favor of PHPMailer. It is way more flexible, is object oriented, much easier to configure with SMTP and has much better attachments support (if you need it).

To send your email in phpmailer you'll just need something like this to set your SMTP:

$mailer = new PHPMailer();
$mailer->Mailer = 'smtp';
$mailer->Host = '123.456.789.012';
$mailer->From = 'me@myself.com';
$mailer->FromName = 'Me Myself';
$mailer->AddAddress = 'someRecipient@whatever.com';
$mailer->Subject = 'My subject line';
$mailer->Body = 'Your Body text here, in HTML if you set $mailer->IsHtml(true)';
$mailer->Send();

Solution 2:

The issue is that your VPS server is configured to handle mail for your domain. Adjust your mail configuration accordingly. Also, Linux ignores the SMTP setting. Only Windows uses this.

Alternatively, you can use a class like PHPMailer which can connect to a remote SMTP server directly.

Post a Comment for "Email And Web Split On Different Servers: Send Email Via Php To An Email On That Domain"