Jump to content

help with code


myshipper

Recommended Posts

i would like the admin to receive the email when someone applies not the company

i know its a small tweek but i just know how to munipulate not write

please help

 

class Postman

{

var $mAdminEmail = ADMIN_EMAIL;

 

function __construct()

{ }

 

// Send a job post to a friend

public function MailSendToFriend($friend_email, $my_email)

{

$subject = 'I\'m recommending you a job ad';

$msg = $_SERVER['HTTP_REFERER'];

$msg .= "\n\n---\nYou've received this e-mail from " . $my_email;

 

if ($friend_email != '' && $my_email != '' && validate_email($friend_email) && validate_email($my_email))

{

if (mail($friend_email, $subject, $msg, 'From: ' . $my_email))

{

return true;

}

else

{

return false;

}

}

else

{

return false;

}

}

 

// Send email to company when applying online

public function MailApplyOnline($data)

{

$extra = '\n\n---\nThis e-mail is an application sent from ' . $_SERVER['HTTP_REFERER'];

 

$mail = new PHPMailer();

 

$mail->From    = stripslashes($data['apply_email']);

$mail->FromName = stripslashes($data['apply_name']);

 

    $mail->Body    = str_replace(array('\r\n', '\r', '\n'), '<br />', stripslashes($data['apply_msg']) . $extra);

    $mail->AltBody = $data['apply_msg'] . $extra;

$mail->Subject = "[" . SITE_NAME . "] I wish to apply for '" . $data['job_title'] . "'";

    $mail->AddAddress($data['company_email'], $data['company_name']);

if ($data['attachment_path'])

{

    $mail->AddAttachment($data['attachment_path'], $data['attachment_filename']);

}

 

if ($mail->Send())

{

return true;

}

else

{

return false;

}

}

 

// Send mail to admin when a job is posted

public function MailPublishToAdmin($data)

{

$msg = '';

$job_title = BASE_URL . 'job/' . $data['id'] . '/' . $data['url_title'] . '/';

$subject = "[" . SITE_NAME . "]" . $job_title;

 

if ($data['check_poster_email'] == 0)

{

$msg .= "Activate ad: " . BASE_URL . "activate/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\n\n\n";

}

$msg .= $job_title;

$msg .= "\n\n" . $data['title'] . " at " . $data['company'];

$msg .= "\n\n" . $data['description'];

$msg .= "\n\nURL: " . $data['url'];

$msg .= "\n\n---\Published by: " . $data['poster_email'];

$msg .= "\n---\nEdit: " . BASE_URL . "post/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\nDeactivate: " . BASE_URL . "deactivate/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\n\n---\nIP: " . $_SERVER['REMOTE_ADDR'];

$msg .= "\nDate: " . $data['created_on'];

mail(NOTIFY_EMAIL, $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");

}

 

Link to comment
Share on other sites

So u want the admin to recive the email aswell, or just the admin to recive the email?

 

 

 

 

 

 

 

This post is just simply for my eyes:

 

<?php
class Postman
{
   var $mAdminEmail = ADMIN_EMAIL;
   
   function __construct()
   { }

   // Send a job post to a friend
   public function MailSendToFriend($friend_email, $my_email)
   {
      $subject = 'I\'m recommending you a job ad';
      $msg = $_SERVER['HTTP_REFERER'];
      $msg .= "\n\n---\nYou've received this e-mail from " . $my_email;

      if ($friend_email != '' && $my_email != '' && validate_email($friend_email) && validate_email($my_email))
      {
         if (mail($friend_email, $subject, $msg, 'From: ' . $my_email))
         {
            return true;
         }
         else
         {
            return false;
         }
      }
      else
      {
         return false;
      }
   }
   
   // Send email to company when applying online
   public function MailApplyOnline($data)
   {
      $extra = '\n\n---\nThis e-mail is an application sent from ' . $_SERVER['HTTP_REFERER'];
   
      $mail = new PHPMailer();

      $mail->From     = stripslashes($data['apply_email']);
      $mail->FromName = stripslashes($data['apply_name']);

    $mail->Body    = str_replace(array('\r\n', '\r', '\n'), '<br />', stripslashes($data['apply_msg']) . $extra);
    $mail->AltBody = $data['apply_msg'] . $extra;
      $mail->Subject = "[" . SITE_NAME . "] I wish to apply for '" . $data['job_title'] . "'";
    $mail->AddAddress($data['company_email'], $data['company_name']);
      if ($data['attachment_path'])
      {
       $mail->AddAttachment($data['attachment_path'], $data['attachment_filename']);
      }

      if ($mail->Send())
      {
         return true;
      }
      else
      {
         return false;
      }
   }
   
   // Send mail to admin when a job is posted
   public function MailPublishToAdmin($data)
   {
      $msg = '';
      $job_title = BASE_URL . 'job/' . $data['id'] . '/' . $data['url_title'] . '/';
      $subject = "[" . SITE_NAME . "]" . $job_title;
      
      if ($data['check_poster_email'] == 0)
      {
         $msg .= "Activate ad: " . BASE_URL . "activate/" . $data['id'] . "/" . $data['auth'] . "/";
         $msg .= "\n\n\n";
      }
      $msg .= $job_title;
      $msg .= "\n\n" . $data['title'] . " at " . $data['company'];
      $msg .= "\n\n" . $data['description'];
      $msg .= "\n\nURL: " . $data['url'];
      $msg .= "\n\n---\Published by: " . $data['poster_email'];
      $msg .= "\n---\nEdit: " . BASE_URL . "post/" . $data['id'] . "/" . $data['auth'] . "/";
      $msg .= "\nDeactivate: " . BASE_URL . "deactivate/" . $data['id'] . "/" . $data['auth'] . "/";
      $msg .= "\n\n---\nIP: " . $_SERVER['REMOTE_ADDR'];
      $msg .= "\nDate: " . $data['created_on'];
      mail(NOTIFY_EMAIL, $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");
   }

?>

Link to comment
Share on other sites

I'm still not fully sure what you want to do but I think what you want to do is have the admin receive an e-mail when  public function MailApplyOnline($data) is used. If this is correct you can modify this line.

 

   $mail->AddAddress($data['company_email'], $data['company_name']);

 

I'm not sure where $data is coming from I can only assume it's a array with the key's of company_email and company_name.

 

If this is so one way to modify it may be to. change

 public function MailApplyOnline($data)

 

to

 public function MailApplyOnline($data,$admin_email,$admin_name)

 

then

$mail->AddAddress($data['company_email'], $data['company_name']);

 

to:

$mail->AddAddress($admin_email'], $data['admin_name']);

 

then when you call the function use

MailApplyOnline(array,'admin@example.com','admin name'

 

I hope this helps.

 

I hope you don't find this rude but did you cut and paste snippes of code from various places the format and variables of all three functions seem to be different.

 

 

Link to comment
Share on other sites

i used the two part but the use funtion i don;t know where to place it

i get a blank screen with the first two changes without placing the use funtion

no this was how it is coded from the script

 

here is the whole page

 

<?php

/**

* jobber job board platform

*

* @author    Filip C.T.E. <http://www.filipcte.ro> <me@filipcte.ro>

* @license    You are free to edit and use this work, but it would be nice if you always referenced the original author ;)

*            (see license.txt).

*

* Postman class is a generic class that handles all e-mail operations

*/

 

class Postman

{

var $mAdminEmail = ADMIN_EMAIL;

 

function __construct()

{ }

 

// Send a job post to a friend

public function MailSendToFriend($friend_email, $my_email)

{

$subject = 'I\'m recommending you a job ad';

$msg = $_SERVER['HTTP_REFERER'];

$msg .= "\n\n---\nYou've received this e-mail from " . $my_email;

 

if ($friend_email != '' && $my_email != '' && validate_email($friend_email) && validate_email($my_email))

{

if (mail($friend_email, $subject, $msg, 'From: ' . $my_email))

{

return true;

}

else

{

return false;

}

}

else

{

return false;

}

}

 

// Send email to company when applying online

public function MailApplyOnline($data)

{

$extra = '\n\n---\nThis e-mail is an application sent from ' . $_SERVER['HTTP_REFERER'];

 

$mail = new PHPMailer();

 

$mail->From    = stripslashes($data['apply_email']);

$mail->FromName = stripslashes($data['apply_name']);

 

    $mail->Body    = str_replace(array('\r\n', '\r', '\n'), '<br />', stripslashes($data['apply_msg']) . $extra);

    $mail->AltBody = $data['apply_msg'] . $extra;

$mail->Subject = "[" . SITE_NAME . "] I wish to apply for '" . $data['job_title'] . "'";

    $mail->AddAddress($data['company_email'], $data['company_name']);

if ($data['attachment_path'])

{

    $mail->AddAttachment($data['attachment_path'], $data['attachment_filename']);

}

 

if ($mail->Send())

{

return true;

}

else

{

return false;

}

}

 

// Send mail to admin when a job is posted

public function MailPublishToAdmin($data)

{

$msg = '';

$job_title = BASE_URL . 'job/' . $data['id'] . '/' . $data['url_title'] . '/';

$subject = "[" . SITE_NAME . "]" . $job_title;

 

if ($data['check_poster_email'] == 0)

{

$msg .= "Activate ad: " . BASE_URL . "activate/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\n\n\n";

}

$msg .= $job_title;

$msg .= "\n\n" . $data['title'] . " at " . $data['company'];

$msg .= "\n\n" . $data['description'];

$msg .= "\n\nURL: " . $data['url'];

$msg .= "\n\n---\Published by: " . $data['poster_email'];

$msg .= "\n---\nEdit: " . BASE_URL . "post/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\nDeactivate: " . BASE_URL . "deactivate/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\n\n---\nIP: " . $_SERVER['REMOTE_ADDR'];

$msg .= "\nDate: " . $data['created_on'];

mail(NOTIFY_EMAIL, $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");

}

 

// Send mail to user when posting first time (thus the post needs to be moderated)

public function MailPublishPendingToUser($poster_email)

{

$subject = 'Your ad on ' . SITE_NAME;

$msg = "Hello! :)\n\n";

$msg .= "We apologize for the inconvenience, but since this is the first time you post with this e-mail address, we need to manually verify it.";

$msg .= "\nThank you for your patience, as the ad should be published ASAP. We'll send you an e-mail when that happens!";

$msg .= "\n\nFrom now on, every ad you post with this e-mail address will instantly be published.";

$msg .= "\n\n---\n\nThank you for using our service!\nThe Team";

 

if ($poster_email != '' && validate_email($poster_email))

{

mail($poster_email, $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");

}

}

 

// Send mail to user when a post is published

public function MailPublishToUser($data, $url=BASE_URL)

{

$subject = 'Your ad on ' . SITE_NAME . ' was published';

$msg = "Hello! :)\n\n";

$msg .= "Your ad was published and is available at: " . $url . "job/" . $data['id'] . "/" . $data['url_title'] . "/";

$msg .= "\n\n---\nEdit it: " . $url . "post/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\nDeactivate it: " . $url . "deactivate/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\n\n---\n\nThank you for using our service!\nThe " . SITE_NAME . " Team";

 

if ($data['poster_email'] != '' && validate_email($data['poster_email']))

{

mail($data['poster_email'], $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");

}

}

 

// Send mail to user when a post is activated (after first-time post)

public function MailPostActivatedToUser($data, $url=BASE_URL)

    {

        $this->MailPublishToUser($data, $url);

    }

 

// Send mail to admin when someone posts a new spam word

public function MailReportSpam($data)

{

$job_title = BASE_URL . 'job/' . $data['id'] . '/' . $data['url_title'] . '/';

$subject = '[sPAM on ' . SITE_NAME . '] ' . $job_title;

$msg .= "Following ad was reported as false/spam:\n--\n\n";

$msg .= $job_title;

$msg .= "\n\n" . $data['title'] . " at " . $data['company'];

$msg .= "\n\n" . $data['description'];

$msg .= "\n\n--- \n Published by: " . $data['poster_email'];

$msg .= "\n---\nEdit: " . BASE_URL . "post/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\nDeactivate: " . BASE_URL . "deactivate/" . $data['id'] . "/" . $data['auth'] . "/";

$msg .= "\n---\nIP: " . $_SERVER['REMOTE_ADDR'];

$msg .= "\nDate: " . $data['created_on'];

 

mail(NOTIFY_EMAIL, $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");

}

 

public function MailContact($name, $email, $msg)

{

$msg .= "\n\n---\nIP: " . $_SERVER['REMOTE_ADDR'];

$msg .= "\nDate: " . date('Y-m-d H:i');

 

$subject = "[" . SITE_NAME . "] contact";

 

if (mail(NOTIFY_EMAIL, $subject, $msg, "From: $name <$email>"))

{

return true;

}

else

{

return false;

}

}

}

?>

Link to comment
Share on other sites

My Shipper,

 

First can I ask of you to wrap all your code in

[ code][ /code] or
 [/quote] I have added spaces so you can see the tags in the forum there is a button you can press that looks like a # sign that will create the tags for you.

Second, it's usually conceded bad form to post an entire page code to a post. It's kinda like saying "do this for me" Often if you post things you've tried or explain what you've read you will be more likely to get help.

With that being said, you are using a php class. I am pretty new to classes but i just googled and found this great article at O'Reilly Net: [url=http://www.oreillynet.com/pub/a/php/2005/07/28/oo_php.html]http://www.oreillynet.com/pub/a/php/2005/07/28/oo_php.html [/url]

the main thing you're have to do is on the page you want to use the functions include the functions page [code]require_once("postmaster.php");[/code]

then create a new object on the new php page

[code]$postmaster_object = new Postmaster;[/code]

then call the function you wish to use

[code]$postmaster_object->MailApplyOnline($data);[/code]

 

This is untested and i just followed the tutorial i linked to above and my own very basic understanding of functions and classes.

 

Hope that helps

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.