Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
    • Guest Posting Service
  • 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

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 👉   password and confirm password validation in html Example

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

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.

Related posts:

  1. How to send Emails with MailGun in Laravel?
  2. Laravel Send Mailgun Mail using PHP cURL
  3. PHPMailer Sending Emails using PHP Code
  4. Multiple image slider in html source code
  5. How To Create Image Hover Overlay Effects?
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

Advertise With Us

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

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 (64) Ajax (464) AngularJS (377) ASP.NET (61) Bio (109) Bollywood (108) Codeigniter (175) CSS (98) Earn Money (93) Education (63) Entertainment (130) fullform (87) Google Adsense (64) Highcharts (77) History (40) Hollywood (109) JavaScript (1359) Jobs (42) jQuery (1423) Laravel (1088) LifeStyle (53) movierulz4 (63) Mysql (1035) Mysqli (894) php (2133) Programming (2345) Python (99) Software (178) Software (90) Stories (98) tamilrockers (104) Tamilrockers kannada (64) Tamilrockers telugu (61) Tech (147) Technology (2416) Tips and Tricks (130) Tools (214) Top10 (505) Trading (94) Trending (76) VueJs (250) Web Technology (112) webtools (200) wordpress (166) World (343)

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
  • Info Grepper
  • 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

© 2023 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 Guest Posting Sites