Catch failed recipients in Symfony/Mailer 6.x? - symfony-mailer

In want replace deprecated SwiftMailer v6.3.0 with new Symfony/Mailer v6.x. In old SwiftMailer I collect failed recipients so that I know who has not received mail.
$successfulRecipients = $mailer->send($message, $failedRecipients);
Symfony/Mailer is not working this way. How do I find failed recipients in Symfony/Mailer? Maybe with try/catch for TransportExceptionInterface but there is no example what exactly is returned.
How do I get the mail addresses which have not received the mail? Because maybe their mailbox was full or the mail was too big?

When symfony successfully hands a mail over to the transport server (e.g. SMTP) it is concidered done for symfony.
As you wrote you may can fetch issues with the transport server by using TransportExceptionInterface. This is done by simple try/catch
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
$email = new Email();
try {
$mailer->send($email);
} catch (TransportExceptionInterface $e) {
echo $e->getDebug();
// error message or try to resend the message
}

Related

Twitter API issue (code: 349, message: 'You cannot send messages to this user.') in node.js

I am sending message by using direct_messages/events/new method in Node.js by using API,
But i am getting the errors like { code: 349, message: 'You cannot send messages to this user.' }
please help me to solve this issue.
Thanks
If the user is not following you or has blocked you, then you will not be able to send messages to the user.
You can also send messages to a user that is not following you but has DM'd you (e.g. if your id accepts DMs without requiring mutual following). However, if the user is not following you/has blocked you (as mentioned by Andy Piper) or has not DM'd you, you'll receive the "code: 349, message: 'You cannot send messages to this user.'" error. Tested via postman using the direct message api (https://api.twitter.com/1.1/direct_messages/events/new.json).

How do I roll-back a message to Amazon MQ (AMQ) from Lambda?

So, I assume this relates to any Node.js and Active MQ installation but I am using Amazon MQ with Node.js Lambda...
Kind of a noob on ActiveMQ so please correct me where I am wrong!
After reading a message from a queue using stompit I continue processing the message and it shall then be sent over HTTPS to another server.
There is some message validation and enrichment happening on the way to the HTTPS POST, and of course the POST itself can result in an error.
How would I (best) handle a roll-back of the message in case of an error:
1) Keep the connection open and not send client.ack() until I finally got a HTTP 200 back from remote server?
2) Keep the message in a variable and put it back in case of error (sequence doesn't matter?
3) Use something other than stomp?
It is apparently not possible using STOMP so I've changed the code to use the library ampq10 instead.
import amqp10 from 'amqp10';
const AMQPClient = amqp10.Client;
const amqpClient = new AMQPClient({
receiverLink: {
attach: {
rcvSettleMode: amqp10.Constants.receiverSettleMode.settleOnDisposition
},
creditQuantum: 1
}
});
This will allow you to do a receiver.accept(message); if successfully handling the message. If you just .disconnect() whitout an .accept() the message will not be removed from the queue.

Ignore invalid messages in reply channel of TcpOutboundGateway and wait for another reply of same output channel message

I have a specific requirement to digest some unwanted message types in the reply channel of TcpOutboundGateway and continue waiting until it comes with a valid message.
I send a message in output channel of TcpOutboundGateway and get an acknowledgment in reply channel. But there are chances I might get an invalid acknowledgment message for the sent message. So I should ignore the invalid message got in reply channel and still wait for a valid message to come.
How to handle this?
The AbstractConnectionFactory can be supplied with the:
public void setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) {
The TcpConnectionInterceptorFactoryChain should be supplied with the custom TcpConnectionInterceptorFactory to produce some custom TcpConnectionInterceptorSupport to intercept that message in the overridden public boolean onMessage(Message<?> message) { and don't let it go to the super.onMessage().
See more info in the Reference Manual.

Expected response code 250 but got code "", with message "" When sending emails with Amazon SES and Swiftmailer

Sending emails that way used to work fine but the other day, in the mail of a script sending a lot of emails, I started getting this error for every email sent:
"Expected response code 250 but got code "", with message """
I cannot find any help on the Amazon SES website.
Many thanks.
in my case it was because of email processing handled by queue worker, and it looks like transport is open until worker process end, so Swiftmailer send many emails in long-running connection and at some point SMTP server closes connection on timeout.
this code helps if used before $this->mailer->send()
if ($this->mailer->getTransport()->isStarted()) {
$this->mailer->getTransport()->stop();
}

Pusher subscription fails silently

I am subscribing to a channel in Pusher on my local machine using the Javascript SDK, and I don't get any error.
However, when I publish an event to that channel it is not received by the subscriber.
I've looked at Pusher's debug console and saw that the message is indeed sent but the subscription never occurs, as the connection is somehow interrupted, apparently prior to the subscription request (i.e I get a disconnection message, as shown in the console screenshot below).
the code is pretty boilerplate:
var pusher = new Pusher('PUSHER_KEY');
channel = pusher.subscribe('game' + game.gameId);
channel.bind('statusChange', function(game) {
console.log("GOT PUSHER - STATUS " + game.status);
$scope.game.status = game.status;
});
Examining the channel.subscribed property shows that the subscription failed as it equals false. I am at the sandbox plan (max 20 connections) and am only using 2 connections.
What can disrupt the connection?
The channel object:
Console screenshot:
I don't know what's the issue exactly but enabling the logs on the client side might help your find it:
Pusher.log = function(message) {
if (window.console && window.console.log) {
window.console.log(message);
}
};
There's some resources on the website to debug that kind of problem too: http://pusher.com/docs/debugging

Resources