Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

size limits in the data array? #46

Closed
codivist opened this issue Apr 22, 2015 · 4 comments
Closed

size limits in the data array? #46

codivist opened this issue Apr 22, 2015 · 4 comments

Comments

@codivist
Copy link
Contributor

When sending emails, one of my email methods has a couple of object passed to the view along with a few variables. When I leave the data array empty or just pass the variables it sends just fine, when passing in the objects I get an InvalidCredentials error:

exception 'Mailgun\Connection\Exceptions\InvalidCredentials' with message 'Your credentials are incorrect.' in /srv/www/example.dev/deploy/match/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:130

Yes I saw #33, but this is different, I have no problems with the validating emails, and emails are sending most of the time.

This one works everytime: (only 2 or 3 variables are passed through $data)

    private function sendTo(User $user, $subject, $view, $data = [], $from = '') {
        return Mailgun::send($view, $data, function ($message) use ($user, $subject, $from) {
            if($from) {
                $message->from($from);
            }
            $message->to($user->email, $user->full_name)
                ->subject($subject);
        });
    }

This one does NOT work: (two object and 3 variables are being passed to $data)

    private function sendToAdmin($adminEmail, $subject, $view, $data = []) {
        return Mailgun::send($view, $data, function ($message) use ($adminEmail, $subject) {
            $message->to($adminEmail)
                ->subject($subject);
        });
    }

when changing the $data to an empty array in the send method it sends.

@codivist
Copy link
Contributor Author

Open mouth 😮 insert foot 👞

In my method where I am getting the error, I have the following line, about 10 lines above, before I send the email

$validateAddress = Mailgun::validate(Input::get('email'));
if(!$validateAddress->is_valid) {
    // return them back to the form
}

Using the Mailgun::validate call is using the public key to validate, and then later on when calling a Mailgun::send it's not switching back to the private key.

Trying some work arounds, but none have been successful yet.

@Bogardo
Copy link
Owner

Bogardo commented Apr 22, 2015

That is odd, I'll see if I can reproduce it.

@codivist
Copy link
Contributor Author

A simple test case that I just tried: (replacing me@example.com with my real email)

        $validateAddress = Mailgun::validate('me@example.com');
        try {
            Mailgun::send('emails.test', [], function ($message) {
                $message->to('me@example.com')
                    ->subject('This is a test');
            });
        } catch(InvalidCredentials $e) {
            var_dump($validateAddress->is_valid);
            return 'api-key problem!';
        }
        dd('done here');

and the email never sends

@Bogardo
Copy link
Owner

Bogardo commented Apr 22, 2015

@codivist Thanks, I'll be at my computer in a couple of hours.
I'm currently working on a new version of this package which is basically a rewrite so I'll see if this issue is present in the new version as well.

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

No branches or pull requests

2 participants