Results 1 to 2 of 2

Thread: send merge mail with hooks

  1. #1
    manulup is offline Junior Member
    Join Date
    Sep 2008
    Posts
    2

    Default send mail with bussiness hooks

    Hi!

    recently i learn about bussiness hooks. I need capture a web lead and before_create send a email to the user.

    i can`t find the email field in $bean->email or $bean->emailAddress->getPrimaryAddress or ... i try but i cant find the solution.

    Here is muy php code.

    <?php

    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class leads_custom{

    function gancho_contacto(&$bean, $event, $arguments){

    // make sure the status was actually changed to closed
    // $bean->fetched_row['status'] is the stored status of the case
    // $bean->status is the status it was changed to
    if ($bean->fetched_row['status'] !== 'Interesado NO contactado' && $bean->status === 'Interesado NO contactado' && $bean->lead_source === 'Self Generated' && $bean->productointeresado_c === 'Secretariado Administrativo'){

    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 = "A pocos pasos del titulo Secretariado Administrativo!";
    global $sugar_config;
    global $app_list_strings;
    global $locale;
    //no va porque no hay nada guardado todavia
    // $emails = $bean->emailAddress->getAddressesByGUID($bean->id, 'Leads');


    $mail->Body = $bean->emailAddress->getPrimaryAddress($bean);


    $mail->AddAddress($bean->email, $bean->contact_name); if ($mail->send()) {
    //cambio el estado a interesado contactado
    $bean->status = 'Interesado CONTACTADO';
    }
    else
    {
    $GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo);
    }

    }
    }
    }

    ?>


    Please help!!!!

    Thanks for all the information on the forum!

    Manuel Lupiaņez
    Last edited by manulup; 2008-09-12 at 12:20 PM.

  2. #2
    manulup is offline Junior Member
    Join Date
    Sep 2008
    Posts
    2

    Default Re: send merge mail with hooks

    Hi!

    recently i learn about bussiness hooks. I need capture a web lead and before_create send a email to the user.

    i can`t find the email field in $bean->email or $bean->emailAddress->getPrimaryAddress or ... i try but i cant find the solution.

    The emails are in other database?
    How can use the imail field of a lead to send a email in a custom bussiness hook?

    Thks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Mail Merge targets or send mailshots to non-email campaign
    By svaish in forum General Discussion
    Replies: 1
    Last Post: 2008-07-24, 03:55 PM
  2. Replies: 0
    Last Post: 2008-02-19, 05:15 AM
  3. how to send mail of campaign in the first time send
    By tinatran in forum General Discussion
    Replies: 5
    Last Post: 2007-12-04, 10:50 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
  •