@weblora
All public web servers expose their public IP addresses. The only IP that is hidden from public access is the private network IP. Anyone could get the IP of a web server by performing a DNS lookup. That said, there’s no need to worry about public IP exposure – properly setting up your firewall will mitigate most common concerns regarding public exposure.
Beyond the firewall, further locking down the droplet and tightening security will further prevent the majority of other cases.
Sending Mail w/ PHP
As far as sending e-mail using PHP, the mail()
function really doesn’t accept connection parameters on the fly so you wouldn’t be connecting to your mail server using this function.
The following lines of code should send an e-mail without any issues:
<?php
$headers = 'From: user@weblora.com' . "\r\n" .
'Reply-To: user@weblora.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
/**
* 1). E-Mail Recipient
* 2). E-Mail Subject
* 3). E-Mail Message
* 4). E-Mail Headers
*/
mail(
'webmaster@weblora.com',
'Testing An E-Mail Using PHP 7',
'This is a test message using PHP 7.x to send.',
$headers
);
… of course, since you’re not connecting to your mail server, this e-mail will most likely end up in the SPAM box of whatever provider it’s being sent to since there’s absolutely zero authentication using the above.
If you want something more advanced, such as actually sending through your mail server, I’d recommend using something such as PHPMailer:
https://github.com/PHPMailer/PHPMailer
or SwiftMailer
https://github.com/swiftmailer/swiftmailer
These libraries provide a feature-rich set of functions that’ll allow you to do what you need to do and connect to your mail server by passing the correct details during configuration.
If you’re using a CMS, such as WordPress, you can use a plugin to handle the connection for you. You can take a look at:
https://wordpress.org/plugins-wp/wp-mail-smtp/
Did you lower your TTLs prior to the inital DNS changeover to CF? When you next try, confirm the following after DNS propagation:
Check MX
Check MX Answer
The above are your current settings and these both should be confirmed after nameserver update for your domain.
If you still can not connect via Thunderbird, test your MTA with Telnet
Regarrrrrrrds… not A pyrate ;0