Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

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.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • 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.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • 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.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.