Results 1 to 6 of 6

Thread: send email in sugarcrm

  1. #1
    akkimca's Avatar
    akkimca is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    270

    Question send email in sugarcrm

    Hi,

    i wrote this php code in my php file called mail.php
    PHP Code:
         require_once('include/SugarPHPMailer.php');
         require_once(
    "modules/Administration/Administration.php");

         
    $mail = new SugarPHPMailer();
         
    $admin = new Administration();
         
         
    $admin->retrieveSettings();
         if (
    $admin->settings['mail_sendtype'] == "SMTP") {
           
    $mail->Host $admin->settings['mail_smtpserver'];
           
    $mail->Port $admin->settings['mail_smtpport'];
           if (
    $admin->settings['mail_smtpauth_req']) {
             
    $mail->SMTPAuth TRUE;
             
    $mail->Username $admin->settings['mail_smtpuser'];
             
    $mail->Password $admin->settings['mail_smtppass'];
           }
           
    $mail->Mailer   "smtp";
           
    $mail->SMTPKeepAlive true;
         }
         else {
           
    $mail->mailer 'sendmail';
         }
         
         
    $mail->From     $admin->settings['notify_fromaddress'];
         
    $mail->FromName $admin->settings['notify_fromname'];
         
    $mail->ContentType "text/html"//"text/plain"
         
         
    $mail->Subject "Hello World!";
         global 
    $sugar_config;
         
         
    $mail->Body "Visit our <a href='".$sugar_config['site_url']."'>SugarCRM</a> instance!";
         
    $mail->AddAddress("recipient@email.com""Recipient Name");
         if (!
    $mail->send()) {
           
    $GLOBALS['log']->info("Mailer error: " $mail->ErrorInfo);
         } 
    when i called this file like http://..../sugarcrm/mail.php
    its giving me this error
    Fatal error: Class 'DBManagerFactory' not found in D:\..\SugarBean.php on line 275
    when i add this class than other errors coming..
    so can anyone tell me how to solve this error and how many files i have to include to run my code ??

    any one help me to send a mail through Sugarcrm code ??

    thanks
    Regards
    ==========================
    akkimca
    Work as Sugarcrm Freelancer
    Feel free to Find me in skype. Its my pleasure to talk with you.
    ID: akshay.biztech

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: send email in sugarcrm

    Consider adding these lines at the top of your script:

    if(!defined('sugarEntry'))define('sugarEntry', true);
    require_once('include/entryPoint.php');
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    mangesh1757 is offline Sugar Community Member
    Join Date
    Jan 2010
    Location
    India
    Posts
    226

    Default Re: send email in sugarcrm

    Hi akkimca,

    If you have created your own page mail.php did you modified "entry_point_registry.php" at
    <root directory>\include\MVC\Controller\entry_point_regi stry.php

    Just a small description if that might help:
    I have created my_custom.php at root and added code in above file as,
    'my_custom' => array('file' => 'my_custom.php', 'auth' => true),

    Now when my_custom.php needs to be called, i have to pass "index.php?entryPoint=my_custom" so that my code gets executed within sugarcrm framework. In your case it will be firing mail.

    Let me know if this worked for you.

    Thanks.

    PS : Make sure that mails are fired from Email Tab of sugarcrm which confirms that all settings required to fire a mail are set properly and then give a go for above procedure
    Last edited by mangesh1757; 2010-03-27 at 09:55 AM.

  4. #4
    hdanielb's Avatar
    hdanielb is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Argentina
    Posts
    40

    Default Re: send email in sugarcrm

    Good point! this is excellent! now, suppose that my_custom have parameters.. do you pass them just including them in index.php call?
    Daniel Blanco
    Director
    Blanco Martin & Asociados
    Worldwide Hosted Software Solutions

    Visit us at www.blancomartin.com.ar

  5. #5
    adam.frank is offline Senior Member
    Join Date
    Aug 2008
    Location
    Sydney, Australia
    Posts
    142

    Default Re: send email in sugarcrm

    Yes for POST, I haven't tested for GET.
    Adam Frank
    Consultant, Loaded Technologies
    adam.frank@loadedtech.com.au

  6. #6
    agcopley is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Santiago, Chile
    Posts
    204

    Default Re: send email in sugarcrm

    Quote Originally Posted by hdanielb View Post
    Good point! this is excellent! now, suppose that my_custom have parameters.. do you pass them just including them in index.php call?
    Hi Daniel,
    Simple add them as part of the query string

    PHP Code:
    index.php?entryPoint=mycustom&param1=val1&param2=val2 
    Slds
    Andrew

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I can't send out campaign but can send out normal Email.
    By yu xintian in forum Marketing/Campaign Management
    Replies: 1
    Last Post: 2010-01-12, 09:02 AM
  2. Replies: 2
    Last Post: 2009-04-30, 03:39 AM
  3. How To: Send Email in SugarCRM
    By Superman in forum Developer Help
    Replies: 1
    Last Post: 2008-02-09, 05:39 AM
  4. send test email vs send email
    By tpascubarat in forum Help
    Replies: 2
    Last Post: 2008-01-20, 03:49 AM
  5. Replies: 0
    Last Post: 2007-09-12, 07:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •