1

I am using mailgun to send email, the attachment doesn't goes through email, works

function send_mail($email,$subject,$msg) {
 $api_key="key-532cf742c1";/* Api Key got from https://mailgun.com/cp/my_account */

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
 curl_setopt($ch, CURLOPT_USERPWD, 'api:'.$api_key);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
 curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/test.com/messages');
 curl_setopt($ch, CURLOPT_POSTFIELDS, array(
  'from' => 'Open <test@gmail.com>',
  'to' => $email,
  'subject' => $subject,
  'html' => $msg,
  'attachment'=>"/home/public_html/cms/upload/quiz.jpg"
));

 $result = curl_exec($ch);
 curl_close($ch);
 return $result;
 }
user580950
  • 3,558
  • 12
  • 49
  • 94

0 Answers0