Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to Office 365 from Webhoste but local it functions. #483

Closed
marciseli opened this issue Sep 3, 2015 · 0 comments
Closed

Comments

@marciseli
Copy link

I use PHPMailer to send us connection requests. Local I use XAMPP with PHP Version 5.6.11. Our Hoster use PHP Version 5.6.3.
When I trie to send the mail from our hoster it doesn't work but it does from XAMPP.
From Web I get this Error message:

2015-09-03 07:24:00 Connection: opening to smtp.office365.com:587, timeout=300, options=array ( ) 2015-09-03 07:24:00 Connection: opened 2015-09-03 07:24:00 SERVER -> CLIENT: 220 DB4PR08CA0009.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 3 Sep 2015 07:24:00 +0000 2015-09-03 07:24:00 CLIENT -> SERVER: EHLO test.subris.ch 2015-09-03 07:24:00 SERVER -> CLIENT: 250-DB4PR08CA0009.outlook.office365.com Hello [136.243.34.153] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-8BITMIME 250-BINARYMIME 250 CHUNKING 2015-09-03 07:24:00 CLIENT -> SERVER: STARTTLS 2015-09-03 07:24:00 SERVER -> CLIENT: 220 2.0.0 SMTP server ready 2015-09-03 07:24:00 SMTP Error: Could not connect to SMTP host. 2015-09-03 07:24:00 CLIENT -> SERVER: QUIT 2015-09-03 07:24:00 SERVER -> CLIENT: 2015-09-03 07:24:00 SMTP ERROR: QUIT command failed: 2015-09-03 07:24:00 Connection: closed 2015-09-03 07:24:00 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Here the code I used:
require ($_SERVER['DOCUMENT_ROOT'] . '/controllers/phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();

        $mail->IsSMTP();
        $mail->SMTPAuth = true; 
        $mail->Host = 'smtp.office365.com';
        $mail->Port = 587;
        $mail->Username = 'mail adress'; 
        $mail->Password = '';  
        $mail->SMTPSecure = "tls";
        $mail->SMTPDebug  = 3;     
        $mail->From     = 'mail adress'; 
        $mail->FromName = '';
        $mail->AddAddress('mail adress'); 
        $mail->Subject = 'Kontaktanfrage'; 
        $mail->IsHTML(true);
        $mail->Body     = '<html><bod>test</body></html>'; 
        $mail->CharSet  =  'utf-8'; 
        if(!$mail->Send()) {
        echo "<p>Mailer Error: " . $mail->ErrorInfo." </p>";
        } else {
        echo "<p>Message sent!</p>";
        }

Can you help me?

Cheers Marc

@Synchro Synchro closed this as completed Sep 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants