Skip to content

Sending emails #28

@danio0701

Description

@danio0701

I setup install all by composer but when I try to sent email I get all time errors:

My code is:
`<?php
require DIR . '/vendor/autoload.php';

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

use \Tx\Mailer;

$ok = (new Mailer())
->setServer('poczta.o2.pl', '465')
->setAuth('[email protected]', 'PASSWORD')
->setFrom('Andrej', '[email protected]')
//->setFakeFrom('Obama', '[email protected]') // if u want, a fake name, a fake email
->addTo('KnicatBakery', '[email protected]')
->setSubject('Hello')
->setBody('Hi, Jerry! I love you.')
//->addAttachment('host', '/etc/hosts')
->send();
var_dump($ok);
`

and get reply:
Fatal error: Uncaught Tx\Mailer\Exceptions\SMTPException: SMTP Server did not respond with anything I recognized in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php:459 Stack trace: #0 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(206): Tx\Mailer\SMTP->getCode() #1 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(169): Tx\Mailer\SMTP->connect() #2 /smtp/vendor/txthinking/mailer/src/Mailer.php(193): Tx\Mailer\SMTP->send() #3 /smtp/index.php(21): Tx\Mailer->send() #4 {main} thrown in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php on line 459

When I setup all for gmail account I get diffrent error:

I change only settings:
$ok = (new Mailer()) ->setServer('smtp.gmail.com', '25') ->setAuth('[email protected]', 'PASSWORD') ->setFrom('DJ', '[email protected]') //->setFakeFrom('Obama', '[email protected]') // if u want, a fake name, a fake email ->addTo('KnicatBakery', '[email protected]') ->setSubject('Hello') ->setBody('Hi, Jerry! I <strong>love</strong> you.') //->addAttachment('host', '/etc/hosts') ->send(); var_dump($ok);

Reply:

Fatal error: Uncaught Tx\Mailer\Exceptions\CodeException: Unexpected return code - Expected: 334, Got: 530 | 530 5.7.0 Must issue a STARTTLS command first. s11sm786228lfr.290 - gsmtp in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php:285 Stack trace: #0 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(178): Tx\Mailer\SMTP->authLogin() #1 /smtp/vendor/txthinking/mailer/src/Mailer.php(193): Tx\Mailer\SMTP->send() #2 /smtp/index.php(21): Tx\Mailer->send() #3 {main} thrown in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php on line 285

I tried also to change:
->setServer('smtp.gmail.com', '465') and ->setServer('smtp.gmail.com', '587')

but for 465 I get same error:
Fatal error: Uncaught Tx\Mailer\Exceptions\SMTPException: SMTP Server did not respond with anything I recognized in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php:459 Stack trace: #0 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(206): Tx\Mailer\SMTP->getCode() #1 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(169): Tx\Mailer\SMTP->connect() #2 /smtp/vendor/txthinking/mailer/src/Mailer.php(193): Tx\Mailer\SMTP->send() #3 /smtp/index.php(21): Tx\Mailer->send() #4 {main} thrown in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php on line 459

for 587:
Fatal error: Uncaught Tx\Mailer\Exceptions\SMTPException: SMTP Server did not respond with anything I recognized in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php:459 Stack trace: #0 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(206): Tx\Mailer\SMTP->getCode() #1 /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php(169): Tx\Mailer\SMTP->connect() #2 /smtp/vendor/txthinking/mailer/src/Mailer.php(193): Tx\Mailer\SMTP->send() #3 /smtp/index.php(21): Tx\Mailer->send() #4 {main} thrown in /smtp/vendor/txthinking/mailer/src/Mailer/SMTP.php on line 459

Any advice please how to setup it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions