Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

PHP Mailgun Sending Emails Tutorials

January 15, 2019 Pakainfo Programming, php Leave a comment

Today, We want to share with you PHP Mailgun Sending Emails Tutorials.In this post we will show you send Emails with MailGun in PHP, hear for Send and Receive Email in PHP Using Mailgun we will give you demo and example for implement.In this post, we will learn about Send email in PHP through email sending services with an example.

PHP Mailgun Sending Emails Tutorials

Contents

  • PHP Mailgun Sending Emails Tutorials
    • PHP Sending Mail using Mailgun
    • PHP Sending Emails with Mailgun Example
    • Read
    • Summary
    • Related posts

There are the Following The simple About PHP Mailgun Sending Emails Tutorials Full Information With Example and source code.

As I will cover this Post with live Working example to develop Sending Emails with PHP and Mailgun, so the some major files and Directory structures for this example is following below.

PHP Sending Mail using Mailgun

function sendMailgunEmail()
{
    $from = "[email protected]";
    $mailgun_post_array_data=array(
        'from'    => 'Free Download PHP Projects and Demo by Pakainfo <'.$from.'>',
        'to'      => '[email protected]',
        'h:Reply-To'=>'[email protected]',
        'subject' => "Free Download Source code with Examples",
        'html'    => "Welcome to Pakainfo.com with Examples and Demo",
    );
    $mailgun_curl = "https://api.mailgun.net/v3/pakainfo.com/messages";

    $curl = curl_init($mailgun_curl);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "api:key-25jd2kk0c2ak9h7s7s29rd692cd89k88"); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    
    curl_setopt($curl, CURLOPT_POSTFIELDS, $mailgun_post_array_data);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
    
    $data_results = curl_exec($curl);  
    $response = json_decode($data_results);
    curl_close($curl);
}

view/etemplate_header_mail.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" >
        <center>
            <table border="0" cellpadding="0" cellspacing="0" width="100%" >
                <tr>
                    <td valign="top" class="bodyContent" >

view/etemplate_footer_mail.php

<?php global $allUserData; global $hideFooter;
if(isset($allUserData['action']) && $allUserData['action']=="hide_email_footer" && in_array($allUserData['shop_id'],$hideFooter)) { ?>

<?php } else{  ?>
                        <br/>
                        <br/>
                    <?php } ?>
                    </td>
                </tr>
            </table>
        </center>
    </body>
</html>

PHP Sending Emails with Mailgun Example

config.php

Free Live Chat for Any Issue

In this(Mailgun setup with PHP example) : PHP send email using in MailGun with More Example Like as PHP email template, mailgun port, mailgun sandbox, mailgun login, mailgun receive email, mailgun relaying denied, postfix mailgun, check mailgun status

Also Read This πŸ‘‰   vue router change route programmatically

function sendEmail($to,$subject,$body,$from = "")
{
    if($from == ""){
        $from = "[email protected]";
    }
    
    ob_start();
        include( "view/etemplate_header_mail.php");
    $template_header_mail = ob_get_clean();
    
    ob_start();
        include( "view/etemplate_footer_mail.php");
    $template_footer_mail = ob_get_clean();

    $mails = [];
    
    foreach ($to as $key => $val) {
        array_push($mails,$val['email']);
    }
    
    $mailgun_post_array_data=array(
        'from'    => 'Free Download PHP Projects and Demo by Pakainfo <'.$from.'>',
        'to'      => implode(",",$mails),
        'subject' => $subject,
        'html'    => $template_header_mail.$body.$template_footer_mail,
    );
    
    
    $mailgun_curl = "https://api.mailgun.net/v3/pakainfo.com/messages";

    $curl = curl_init($mailgun_curl);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "api:key-25jd2kk0c2ak9h7s7s29rd692cd89k88"); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    
    curl_setopt($curl, CURLOPT_POSTFIELDS, $mailgun_post_array_data);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
    
    $data_results = curl_exec($curl);  
    $response = json_decode($data_results);
    curl_close($curl);

}

Angular 6 CRUD Operations Application Tutorials

Read :

  • Technology
  • Google Adsense
  • Programming
Also Read This πŸ‘‰   How to send Emails with MailGun in Laravel?

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Mailgun Sending Emails Tutorials.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Pakainfo
Pakainfo

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Also Read This πŸ‘‰   CheckBoxes using Angular Example

Related posts:

  1. How to send Emails with MailGun in Laravel?
  2. Laravel Send Emails Mailgun setup Tutorial
  3. Laravel Send Mailgun Mail using PHP cURL
  4. PHPMailer Sending Emails using PHP Code
  5. Sending Bulk Emails in PHP with PHPMailer
  6. Laravel 5.6 Sending Emails using SMTP Tutorial
  7. Multiple image slider in html source code
  8. How To Create Image Hover Overlay Effects?
  9. Simple Laravel Sending Emails Example
  10. PHP Sending Mail Contact Form with jQuery AJAX
Free Online Tutorials and CoursesHow to Send and Receive Email in PHP Using MailgunHow to send Emails with MailGun in PHPmailgun loginmailgun portmailgun receive emailmailgun relaying deniedmailgun sandboxMailgun setup with PHP examplePHP email templatePHP Sending Emails with Mailgunpostfix mailgunSend email in PHP through email sending servicesSending Emails with PHP and MailgunSending Mail using Mailgun

Post navigation

Previous Post:jQuery Check Uncheck All Checkbox Examples
Next Post:Vue Tabs Components vue-nav-tabs

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (58) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (102) Codeigniter (175) CSS (98) Earn Money (61) Education (56) Entertainment (123) fullform (82) Google Adsense (62) Highcharts (77) Hollywood (103) JavaScript (1356) Jobs (40) jQuery (1422) Laravel (1087) LifeStyle (51) movierulz4 (57) Mysql (1029) Mysqli (890) Node.js (39) php (2117) Programming (2330) Python (96) ReactJS (37) Software (137) Software (83) Stories (95) tamilrockers (98) Tamilrockers kannada (58) Tamilrockers telugu (57) Tech (133) Technology (2379) Tips and Tricks (113) Tools (177) Top10 (399) Trading (74) Trending (63) VueJs (250) Web Technology (97) webtools (180) wordpress (166) World (219)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • Guest Posting Sites
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

Β© 2022 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype YouTube Tag Extractor