I am trying to send url as attachment using Send Email api in Mailgun. But the attachment is not attached. I am using Laravel HTTP client
$params = [
'from' => $selected_options['mg_from_email'],
'to' => $selected_options['mg_to_email'],
'subject' => $selected_options['mg_subject'],
'text' => $selected_options['mg_text'],
'html' => $selected_options['email_body'],
];
$response = Http::asForm()->withOptions(['verify' => config('constants.verify_ssl')])->timeout(30)->withHeaders(
[
'Content-Type' => 'multipart/form-data',
'Authorization' => 'Basic ' . base64_encode('api:'.$api_key)
]
)->attach(
'attachment', file_get_contents('https://picsum.photos/200'), 'photo.jpg'
)->post(
$request_url,
$params,
);
Can anyone suggest what i am doing wrong here?
There is no error in response and the email is also sent successfully but the attachment is not there.