Support » Plugin: WP Mail SMTP by WPForms » how can i catch the errors returned after sending the mail

  • Resolved Matteo182

    (@matteo182)


    i am using AWS for sending mail, some mails return complain after sending, how can I get this complain?

    can i use this hook?
    does it work after sending?

    do_action( ‘wp_mail_smtp_mailcatcher_smtp_send_after’, $is_sent, $to, $cc, $bcc, $subject, $body, $from );

    or the same error I have in this hook is returned by the wp_mail () function?

    what is better to hook to your hook or take the return value of the wp_mail () function?

    thank you very much

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Gregor Capuder

    (@capuderg)

    Hi @matteo182,

    are you using our “Amazon SES” mailer, or our “Other SMTP” mailer? The hook you mentioned runs only for the “Other SMTP” mailer…

    If you are looking for a solution for the “Amazon SES” mailer, please take a look at the wp_mail_smtp_mailcatcher_send_after hook in the plugin code. You will get access to the is_email_sent and get_response_error methods on the $mailer object. I think that’s what you are looking for. The first method just returns a boolean if the email was sent or not (just like the wp_mail function does). The second should tell you what kind of an error AWS SES API returned when the email was attempted to send.

    Have a nice day!

    Thread Starter Matteo182

    (@matteo182)

    ok then I buy the PRO of the plugin and configure Amazon SES,

    in this way I can connect to the hook ‘wp_mail_smtp_mailcatcher_send_after’ and check if AWS returns me a complain after sending the mail?
    and i access to $mailer[‘get_response_error’] == ‘complain’ for exemple
    quite right ?

    thank you very much

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi @matteo182,

    the first parameter of the wp_mail_smtp_mailcatcher_send_after hook will be the $mailer object. You can then retrieve the error message that the AWS SES API returns with $mailer->get_response_error(). This will give you the whole error text from the API response if there was an error for that particular email.

    Take care!

    Thread Starter Matteo182

    (@matteo182)

    ok yes thank you very much
    I understood
    Before I did not understand that it was an object

    thank you very much

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.