How to send an email using this file

i found this file library/core/class.email.php

can i send an email using this file. if it is possible how can i send it. could you please give me an example.

Tagged:

Comments

  • hgtonighthgtonight MVP
    edited June 2013

    Paraphrased from class.activitymodel.php line 549:

    $Email = new Gdn_Email();
    $Email->Subject('Your subject');
    $Email->To('address@example.com', 'Name');
    $Email->Message('Your Message');
    
    try {
      $Email->Send();
      $Emailed = 2; // similar to http 200 OK
    } catch (phpmailerException $pex) {
      if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
        $Emailed = 4;
      else
        $Emailed = 5;
    } catch (Exception $ex) {
      $Emailed = 4; // similar to http 5xx
    }
    

    Then you can do something based on the value of $Emailed. 2 means a success in this case.

  • ChanuxChanux ✭✭

    @vrijvlinder could you please help me ?

  • What are you trying to do ? Just send mail ? from inside the dashboard or outside?
    Please explain more detail of what you need .

  • ChanuxChanux ✭✭
    edited June 2013

    @vrijvlinder There is a file in customepage plugin.

    file pathplugin/customepage/pages/email.php

    i want to send an email, when refresh the file

  • I have not seen that file , is it a custom page you made and added email.php?

    Will this be mail you send to people or mail people will send to you ?

  • ChanuxChanux ✭✭

    it is custome page made by me. as example..

    to > Sesion User

    From > Forum email

  • But you can send message to user no? PM plugin , or do you mean send email to user's email from inside the forum?

    I'm sorry I can't think of anyway to do this at the moment . You might be able to modify the Contact plugin or another plugin that send mail and incorporate it to the page.

  • peregrineperegrine MVP
    edited June 2013

    hgtonight - already showed him how in the second message above

    just fill in the session user name and email address in the to field.

  • ChanuxChanux ✭✭

    @hgtonight Its working perfect. @vrijvlinder @peregrine Thanx for everything. :)

  • ChanuxChanux ✭✭

    @hgtonight can i send cc or bcc email with this code ?

  • Yes. Just use $Email->Cc('address@example.com', 'Their Name'); and $Email->Bcc('address@example.com', 'Their Name');. You can also pass an array of email addresses as the first argument.

Sign In or Register to comment.