I am trying to send an email using phpmailer. I have set the encryption to “none” to send using plaintext, however, it starts TLS. I am able to telnet manually to the server and successfully send the email in plaintext, meaning that the server supports plaintext and is not enforcing TLS. Here are the settings and traffic capture:
$mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = MAILSRV; $mail->Port = "25"; $mail->SMTPSecure = "none"; $mail->SMTPAuth = "1"; $mail->Username = MAILUSER; $mail->Password = MAILPASS; $mail->IsHTML(true); $mail->setFrom(MAILFROM, "Test"); $mail->CharSet = "utf-8"; $mail->Encoding = "base64"; $mail->addAddress(MAILTO); $mail->Subject = SUBJECT; $mail->msgHTML(BODY);
Server sends RST after client hello. How can I configure phpmailer to send the email with no encryption?
Advertisement
Answer
Don’t make up random stuff and expect it to work; pay attention to the correct types and values of PHPMailer properties, ideally by reading the API documentation.
$mail->Port = "25";
Port
is an integer, not a string.
$mail->SMTPSecure = "none";
If you’re trying to turn it off, set it to an empty string (as the source code says), not some random value, though it is off by default so you don’t have to do this anyway.
$mail->SMTPAuth = "1";
This is a boolean value, and it already defaults to false.
$mail->Encoding = "base64";
This is generally a bad idea, and makes your messages more likely to be classified as spam.
But to get to the point of your question, PHPMailer uses opportunistic encryption, meaning that if your server advertises it, PHPMailer will automatically attempt to use it. This can fail in some circumstances, usually when the target mail server is misconfigured in some way, but the thing you are looking for is:
$mail->SMTPAutoTLS = false;
and the documentation on it is here.