Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Send Email from PHP Script

Discussion in 'E-mail Discussion' started by Taha Kirmani, Jan 15, 2015.

  1. Taha Kirmani

    Taha Kirmani Registered

    Joined:
    Jan 15, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Karachi, Pakistan, Pakistan
    cPanel Access Level:
    Website Owner
    Hello

    I am trying to send Email from mochahost server. Their technical representative gave me following link to send mail from mochahost.

    /http://www.mochasupport.com/kayako/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=555

    I have written the following code, but its neither generating any email, nor giving any error message.

    Kindly check the following code and guide me what i am doing wrong here.

    Please also guide me that from where to get Mail.php file

    PHP:

    <?php

    //require_once "Mail.php";
    require "Mail.php";



    $from "Taha <username@Hotmail.com>";


    $to "Taha <username@Hotmail.com>";

    $subject "Hi!";

    $body "Hi,\n\nHow are you?";



    $host "111.11.11.127";

    $username "username@Hotmail.com";

    $password "password";



    $headers = array ('From' => $from,


      
    'To' => $to,

      
    'Subject' => $subject);

    $smtp Mail::factory('smtp',

      array (
    'host' => $host,

        
    'auth' => true,


        
    'username' => $username,

        
    'password' => $password));



    $mail $smtp->send($to$headers$body);



    if (
    PEAR::isError($mail)) {

      echo(
    "<p>" $mail->getMessage() . "</p>");


     } else {

      echo(
    "<p>Message successfully sent!</p>");

     }

    ?>



     
  2. triantech

    triantech Well-Known Member

    Joined:
    Jul 1, 2014
    Messages:
    143
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Kochi, India, India
    cPanel Access Level:
    Root Administrator
    Hey,

    >> Make sure the PEAR Mail package is installed

    Did you get a change to verify this ^ ?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,633
    Likes Received:
    1,787
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello :)

    I suggest consulting with your web hosting provider for assistance with your script if you do not have root access to your server. You won't be able to review Exim logs with just cPanel access.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Taha Kirmani

    Taha Kirmani Registered

    Joined:
    Jan 15, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Karachi, Pakistan, Pakistan
    cPanel Access Level:
    Website Owner
    Thanks everyone for the reply... I have successfully installed the PEAR Mail Package. It has installed it in home/username/Php/Mail ...Now i am unable to understand that how to link this folder from my code... When i am using the following code its giving me the error message that its unable to find out the "Mail.php" file.


    PHP:
    //require "../../php/Mail.php";

    //include 'home/username/php/Mail.php';

    The both code written above is unable to find out the Mail.php file. Kindly guide me how to include "Mail.php" file.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,633
    Likes Received:
    1,787
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    You may find more feedback on a forum dedicated to discussions of PHP programming or from your web hosting provider who can review the script and verify if it should work on their server.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice