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

Add method for reset (restart) transport #8

Closed
unclead opened this issue Jun 1, 2015 · 10 comments
Closed

Add method for reset (restart) transport #8

unclead opened this issue Jun 1, 2015 · 10 comments
Labels

Comments

@unclead
Copy link

unclead commented Jun 1, 2015

I'm using a worker for sending emails which work as a daemon and i noticed that daemon fails with an error when there is a long period between sending emails

Error: fwrite(): send of 6 bytes failed with errno=32 Broken pipe
PHP Notice:  fwrite(): send of 12 bytes failed with errno=32 Broken pipe in .../vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 232

I found the swiftmailer's issue about this problem: swiftmailer/swiftmailer#490

One guy implemented his own extension for laravel that has functional for auto reseting smtp connection.
You can find it here: https://github.com/YOzaz/Laravel-SwiftMailer/blob/master/src/YOzaz/LaravelSwiftmailer/Mailer.php#L128

I think we can implement same functionality for avoid such error

@YOzaz
Copy link

YOzaz commented Jul 27, 2015

Well, this package is almost framework-independent - shouldn't be hard to upgrade for multiple framework support ;)

@klimov-paul
Copy link
Member

Rejected: this issue should be solved at swiftmailer project level.

@YOzaz
Copy link

YOzaz commented Aug 29, 2016

@klimov-paul, my 2 cents: as we have discussed with SwiftMailer author, it should not automatically solve it, as auto-reset is out of project scope and is rather SMTP connection limitation (?). SwiftMailer is only a set of tools, not a framework.
Laravel has already implemented auto-reset functionality in it's latest branch after a long discussion about this.

@klimov-paul
Copy link
Member

it should not automatically solve it, as auto-reset is out of project scope and is rather SMTP connection limitation (?). SwiftMailer is only a set of tools, not a framework.

Well, I can say just the same about this extension. Auto-reset of the SMTP connection is risky, since the reson of its failure is unknown.

The obvious solution for this problem will be extending Swift_SmtpTransport and overridde its send() method with something like following:

public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
    try {
        parent::send($message, $failedRecipients);
    } catch(\Exception $e) {
        $this->restart();
        $this->send($message, $failedRecipients);
    }
}

@klimov-paul
Copy link
Member

This extension simply do not have a proper place for such wrap.

@desmondlee
Copy link

@klimov-paul Hi, Thanks for your help! Would you please tell me how exactly to fix this unusual problem in yii2-framework ?

@cebe
Copy link
Member

cebe commented Jun 5, 2017

@desmondlee the solution is in the comment above. For further help, see below:

@cebe cebe added the question label Jun 5, 2017
@yii-bot
Copy link

yii-bot commented Jun 5, 2017

Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.

We advise you to use our community driven resources:

If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.

This is an automated comment, triggered by adding the label question.

@desmondlee
Copy link

@cebe Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants