Jump to content

Send php mail with SSL


evop

Recommended Posts

Hi People,

 

I'm using a php to send an mail using a server via ssl. My program:

 

<?php
 
require("class/class.phpmailer.php");
 
$mail = new PHPMailer();
 
$mail->IsSMTP();                       // telling the class to use SMTP
 
$mail->SMTPDebug = 1;                  
// 0 = no output, 1 = errors and messages, 2 = messages only.
$mail->SMTPAuth = true;                
$mail->SMTPSecure = "ssl";              
$mail->Host = "webmail.***.srv.br";        
$mail->Port = 587;                     
 
$mail->Username = "user@***.srv.br";  
$mail->Password = "passw";      
 
$mail->CharSet = 'windows-1250';
$mail->From = '"user@***.srv.br';
$mail->AddBCC ( '[email protected]', 'xx'); 
$mail->Subject = $subject;
$mail->ContentType = 'text/plain'; 
$mail->IsHTML(false);
 
$mail->Body = $body_of_your_email; 
// you may also use $mail->Body = file_get_contents('your_mail_template.html');
 
$mail->AddAddress ('[email protected]', 'Recipients Name');     
// you may also use this format $mail->AddAddress ($recipient);
 
if(!$mail->Send()) 
{
        echo "Mailer Error: " . $mail->ErrorInfo;
} else 
{
        echo "Successfully sent!";
}
 
?>
 
but i receive this error:
 
SMTP -> ERROR: AUTH not accepted from server: 503 5.5.1 Error: authentication not enabled SMTP -> ERROR: RCPT not accepted from server: 554 5.7.1 : Client host rejected: Access denied SMTP -> ERROR: RCPT not accepted from server: 554 5.7.1 : Client host rejected: Access denied Mailer Error: Language string failed to load: [email protected], [192.168.9.153]>[192.168.9.153]>[email protected]
 
I tried using command line: openssl s_client -starttls smtp -crlf -connect webmail.***.srv.br:587 and it works!!! Why via php i got the error ?
 
In phpinfo:
OpenSSL support enabled OpenSSL Version OpenSSL 0.9.8h 28 May 2008
 
 
Anyone can help me ?
Thanks.
 
 
Link to comment
https://forums.phpfreaks.com/topic/293168-send-php-mail-with-ssl/
Share on other sites

Interesting. What is your real domain name xxxx.com.br or xxxx.srv.br?

Is this your domain (webmail.telecel.srv.br)

[jazz@centos-box ~]$ nmap --script smtp-open-relay.nse -p 25,465,587 webmail.telecel.srv.br

Starting Nmap 5.51 ( http://nmap.org ) at 2014-12-22 07:38 EST
Nmap scan report for webmail.telecel.srv.br (177.185.197.65)
Host is up (0.20s latency).
PORT    STATE    SERVICE
25/tcp  filtered smtp
465/tcp closed   smtps
587/tcp closed   submission

Nmap done: 1 IP address (1 host up) scanned in 2.36 secon

if so the ports 465 and 587 are closed. You need to tell us 

try $mail->isSendMail() instead of $mail->isSMTP() - I was having a problem yesterday with my remote server and this fix it. So it might be the problem?  An like stated ports 465 or ports 587 need to be commented out $mail->Port = 587. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.