This topic is locked

Nobody

1/25/2007 11:22:11 AM
PHPRunner General questions
M
mmponline author

Any ready to go / easy solution for this in the e-mails sent by PHP Runner?

Or else in the near future?

Alexey admin 1/26/2007

Stephan,
I have no idea what is Nobody you talking about.

Please clarify.

D
dsaunier 1/26/2007

Making a wild guess here, but I'd say you mean email supposedly sent from a phprunner-based application appear as "nobody" to the person receiving them ?

In that case this is server question and you should check the machine hosting your application, or the script may not specify the From adress, in which case the server may add it own config name and the user the app is running as, ie Apache / nobody most of the time ?
regards.

L
larsonsc 1/26/2007

I have a couple form mailers that I use and in order to control the "From" address that comes through on an email, I set it in a variable.

$mailfrom = 'address@domain.com';


The add the following to your mail(); code:

'From: '.$mailfrom


Hope that helps.

M
mmponline author 1/27/2007

I have no idea what is Nobody you talking about.

Please clarify.

If I use an event in PHPRunner to send an e-mail after add or edit, the receiveden a e-mail has a "nobody" in the from line. I would like this to say from: Eg. Stephan or even a e-mail address. When I click reply, it puts in the following address pointing to my server, in stead of to the administrative e-mail address:
nobody@dedi50a.your-server.co.za
Except for the login settings

'From: '.$mailfrom


Where do I add this code if it would work. In an event or a specific file?
Thanks for your help

L
larsonsc 1/27/2007

That code would go in an event, see below for an example:

if (*whatever criteria you want to check*) {
$email = "email@email.com";

$mailfrom = "you@yourdomain.com";

$subject = "Thanks for doing something that triggered an email";

$message = "Glad to have you on our site" . "\n\n";
mail($email, $subject, $message, 'From: '.$mailfrom);
}
L
larsonsc 1/27/2007

...When I click reply, it puts in the following address pointing to my server, in stead of to the administrative e-mail address:

nobody@dedi50a.your-server.co.za


Changing the reply-to address takes a bit more work than the piece of code I provided you. The piece I gave you will only manipulate the displayed "From" address. In order to change the reply-to address, you must assign it usuing a variable and a few other lines of code. I'll get an example of how to change the headers later this evening or tomorrow, but I must run now to an appointment.

M
mmponline author 1/30/2007

if (whatever criteria you want to check) {

$email = "email@email.com";

$mailfrom = "you@yourdomain.com";

$subject = "Thanks for doing something that triggered an email";

$message = "Glad to have you on our site" . "\n\n";
mail($email, $subject, $message, 'From: '.$mailfrom);
}



larsonsc
The code you provided works like a charm. Thanks a lot. I've tweaked it using the standard event to add the changed e-mail data to the mail as well:
{
$email = "email@email.com";

$mailfrom = "you@yourdomain.com";

$subject = "Thanks for doing something that triggered an email";

$message = "Glad to have you on our site" . "\n\n";
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n";
mail($email, $subject, $message, 'From: '.$mailfrom);
}

Now more challenges:

  1. How do I get the return e-mail to be that of the user (drawn from the registration table's e-mail address or the e-mail address in the user's table.
  2. How do I have the e-mail sent to the user as well, as proof Eg. of updating his records.
    Thanks
    Stephan

L
larsonsc 1/30/2007

Now more challenges:


  1. How do I get the return e-mail to be that of the user (drawn from the registration table's e-mail address or the e-mail address in the user's table.
  2. How do I have the e-mail sent to the user as well, as proof Eg. of updating his records.
    Thanks
    Stephan


  1. Does the email for the user that you wish to be the return email address come up in the form when they update their details? If so, what is the DB field name for the email address?
  2. I can knock that out once I know the answer to number 1 I think. We might have to work on a couple things to get it working nice and smooth, but I think we can figure it out.
    Thanks.
    --Shawn

Sergey Kornilov admin 1/30/2007

Stephan,
it all depends where you place this code. Is that a AfterSuccessfulRegistration event?
Btw, PHPRunner has an option to send email to user after registration.

Also you can specify From email address on the same page in PHPRunner.

M
mmponline author 1/30/2007

I got this working with a lot of trial and error. But it works... (It also resolves http://www.asprunner.com/forums/index.php?showtopic=4463 )
This code sends 2 emails. One to the administrator's e-mail and one to the user telling that info was updated. On receiving the mail, it displays the right from mail and not Nobody. On pressing reply, it also adds the correct e-mail in the reply address, as needed.
This can obviously work with add or edit criteria.

function BeforeEdit(&$values, $where)

{

global $conn;
//admin email

$adminemail = "admin@adminemail.com";

$mailfrom1 = "admin@adminemail.com";

//admin message

$subject1 = "The following user updated his information";

$message1 = "Information was edited as follows:" . "\n\n";
foreach($values as $field=>$value)

$message1.= $field." : ".$value."\r\n";
//select user email from LoginTable

$str = "select * from EmplLogin where UserName = '".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$useremail = $data["E-mail"];

$mailfrom2 = $data["E-mail"];

//user message

$message2="Your new info was updated to:"."\n\n";

$subject2="Your data record was updated";
foreach($values as $field=>$value)

$message2.= $field." : ".$value."\r\n";
mail($adminemail, $subject1, $message1, 'From: '.$mailfrom1);

mail($useremail, $subject2, $message2, 'From: '.$mailfrom2);
return true;

}



There's probably some easier ways, but it does what I want. PHPRunner is great. This peace of code is going straight to my snippets database (created wit PHPRunner of course.

L
larsonsc 1/30/2007

Nice work Stephan. Glad you found a solution.