Reputation: 121
I was trying to send emails from my website which is hosted by Hostgator. whenever I try to send SMTP emails via any common port such as 587 or 25 the email works fine with the same code, but when I try to send using port 465 following the host settings it doesn't work and the website stops responding for few minutes on any device connecting from any other IP.
I'm posting this since the host doesn't provide any coding help.
below is the code:
$email = new PHPMailer();
$email->isSMTP();
$email->SMTPDebug = 0;
$email->Debugoutput = 'html';
$email->SMTPAuth = true;
$email->Host = "gatorxxxx.hostgator.com";
$email->Port = 465;
$email->Username = "[email protected]";
$email->Password = "emailpassword";
$email->setFrom('[email protected]', 'Sender Name');
$email->Subject = 'Subject';
$email->MsgHTML($body);
$email->AddAddress( "useraddress" );
$email->AddReplyTo('[email protected]');
if(!$email->Send()) {
header("xxx");
die ();
} else {
header("yyy");
die ();
}
My concern is Port 465 is for authenticated email sending, therefore it has fewer chances to land in recipient's spam folder, while using ports such as 25 or 587 might be unsafe, hence can trigger spam filters from the client side.
Upvotes: 0
Views: 2376
Reputation: 11354
Port 465 is not open on all SMTP hosts, it sounds like you are experiencing a TCP timeout, or your email class doesn't support SSL. Port 465 requires SSL, not STARTTLS as 587 does.
Also the port you submit through has no impact on the spam folder on the client, once your SMTP server @ HostGator get's the email it will relay it to the target server on port 25. The "authenticated email" is just proving you are authorised to relay through the host, it has nothing to do with the content of the email or if it ends up in the spam box.
To avoid spam filtering you need to ensure you have valid SPF records configured, your RDNS is configured and valid in both directions and you DKIM sign your messages.
The best way to handle all this is to run a local SMTP server that you send through that relays to the upstream SMTP server. For example, Postfix with OpenDKIM.
Upvotes: 1