问题
Why this code is giving the error while sending email to mailgun mailing list ?
$mailgun->sendMessage(MAILGUN_DOMAIN,[
'from' => 'test@samples.mailgun.org',
'to' => MAILGUN_LIST,
'subject' => $subject,
'html' => $body.'<br><br><a href="%unsubscribe_url%">Unsubscribe</a>'
]);
The fatal error i am getting is give below:
Fatal error: Uncaught Mailgun\Connection\Exceptions\MissingRequiredParameters: The parameters passed to the API were invalid. Check your inputs! Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in domain settings. in C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php:226 Stack trace: #0 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php(99): Mailgun\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php(151): Mailgun\Connection\RestClient->send('POST', 'sandboxb676bd53...', Object(GuzzleHttp\Psr7\Stream), Array) #2 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Mailgun.php(118): Mailgun\Connection\RestClient->post('sandboxb676bd53...', Array, Array) #3 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Mailgun.php(61): Mailgun\Mailgun->post('sandbox in C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php on line 226
回答1:
Uncaught Mailgun\Connection\Exceptions\MissingRequiredParameters: The parameters passed to the API were invalid. Check your inputs! Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in domain settings
If you are sending from the sandbox domain then you need to configure the allowed recipient list (max 5 users). See here for more details.
I'm also not sure it allows your to send to a mailing list either under the sandbox. Also, your from address should also have the same domain as the sandbox domain.
回答2:
Mailgun Email
$result = $mgClient->sendMessage($domain, array(
'from' => ''.$txt_fname.' <'.$txt_femail.'>',
'to' => ''.$email_address.'',
'subject' => ''.$txt_subject.'',
'text' =>''.$txt_only.'',
'html' => '<html><body>'.$email_message.'</body></html>'
),$file_array);
来源:https://stackoverflow.com/questions/39140281/mailgun-invalid-parameters