Page 1 of 1

e-mail function help

Posted: Fri Jun 06, 2003 10:27 am
by m3rajk
i'm trying to figure out why this doesn't send the bcc.

Code: Select all

<?php

$uid=uniqid(microtime(),1); // make a unique id
session_start(); // start a session
$SESSION['uid']=$uid; // set the uid for the session and validation code

$done=$_GET['done']; $user=$_GET['un']; $email==$_GET['email']; $pass==$_GET['pass']; $puid==$_GET['puid'];


if(isset($done)&&($done='test')){ // send the mail

$to="$email"; $subject='test of e-mail genereation'; $bcc1='removed my e-mail address from this spot';
$header="bcc: $bcc1"; $body="sorry if you got this in err. i hope those that help me test it don't enter random e-mail addresses or use it to spam. this is simply a test of php's e-mail ability. i am testing to see if i have it working right. if you got this in err, alert me by fwding it to 'removed my e-mail address from this spot'. thanx.

if not in err, then let me know if the following is what you entered: 
for a name: $user
for a pass: $pass

and your assigned "validation code" would be: $puid

ask me about the validation code. i should be logging it

-josh";

mail($to, $subject, $body, $header);

?><html><head><title>test</title></head><body><p>thanx for using the test. hit back to go back and test again</p></body></html><?php

}else{ // make the form

?><html><head><title>test of e-mail</title></head>
<body><center><p>testing of e-mail ability of php</p>
<form name="emailtest" method="GET" <?php echo "action="$_SERVER[PHP_SELF]""; ?> >
<input type="hidden" name="puid" <?php echo "value="$uid""; ?> >
<input type="hidden" name="done" value="test">
<table><tr><td>name</td><td><input type="text" name="un"></td></tr>
<tr><td>email</td><td><input type="test" name="email"></td></tr>
<tr><td>pass</td><td><input type="password" name="pass"></td></tr>
<tr><td><input type="submit" value="test me!"></td><td><input type="reset" value="clear me!"></td></tr>
</table></form></center></body></html><?php

}

?>

Posted: Fri Jun 06, 2003 10:31 am
by m3rajk
note: i used get here because i wanted to see the output in the first variation to make sure it matched what was sent, and want to be aable to test it in this one as well.

i plan on making another variation of the test file using post once bcc works, and then taking the e-mail sending section and inserting it into the sign uphaving the unique id provided by that function as a validation code, and later to prevent multiple submissions of each step of the sign up

Posted: Fri Jun 06, 2003 10:36 am
by nielsene
You should be using assignment (single-equals, '=') not equality testing (double-equals, '==') when assigning values out of the $_GET array. But I don't think that's the problem.

Is any mail being sent? Are the to-recipients receiving mail, just not the bcc'd ones?

Posted: Fri Jun 06, 2003 12:01 pm
by twigletmac
Which webserver are you using?

Mac

Posted: Fri Jun 06, 2003 12:15 pm
by m3rajk
Apache/1.3.27 Server at people.brandeis.edu Port 80

i'm using my alma mater in testing right now.. it's a bit faster than the pentium 1 pre-mmx that i've ressurected for later tests.

i'm not sure the php on that one but believe it to be at least 4.

later tests will beon the server i mentioned i'm setting up with apache 2 and php 4.2.2 and mysql 3.23.56

Posted: Fri Jun 06, 2003 12:25 pm
by m3rajk
nielsene wrote:You should be using assignment (single-equals, '=') not equality testing (double-equals, '==') when assigning values out of the $_GET array. But I don't think that's the problem.

Is any mail being sent? Are the to-recipients receiving mail, just not the bcc'd ones?
thanx. i just fixed that.
but that was NOT the issue. the issue was and still is the fact it's not using the header.

anyone know how i can get it to use the header???

from the books i have, that IS the correct use

Posted: Fri Jun 06, 2003 11:17 pm
by m3rajk
apparently the issue is different than i thought....
me: i made a php script do test the mail function
me: doesn't work right
me: it's not doing bcc
friend: ok
me: http://people.brandeis.edu/~m3rajk/JMT/ ... c-try3.php
me: tell me what you think of the validation code
friend: ?
me: did you send it to yourself?
friend: yeah
friend: why?
me: did you get the e-mail yet?
friend: no
me: hmpf
me: it sent it to me.. it's suppossed to sent it to what YOU wrote in.
me: which means it is ONLY sending tot he bcc

Posted: Fri Jun 06, 2003 11:19 pm
by m3rajk
i assume this means i just replace $to with $email in the call and it should work, and for some reason the setting of $to isntt working right. i'll have it checked and report back

Re: e-mail function help

Posted: Fri Jun 06, 2003 11:28 pm
by m3rajk
d-try4.php (c-try3, the one in the im convo is the same withthe exception that $to is used in place of $email in the mail call). try 4 is sending to my friend that's testing it, but not to me. so now the bcc really isn't working.

Code: Select all

<?php

$uid=uniqid(microtime(),1); // make a unique id
session_start(); // start a session
$SESSION['uid']=$uid; // set the uid for the session and validation code

$done=$_POST['done']; $user=$_POST['un']; $email=$_POST['email']; $pass=$_POST['pass']; $puid=$_POST['puid'];


if(isset($done)&&($done='test')){ // send the mail

$to="$email"; $subject='test of e-mail genereation'; $bcc1='removed my e-mail address from this spot';
$header="bcc: $bcc1"; $body="sorry if you got this in err. i hope those that help me test it don't enter random e-mail addresses or use it to spam. this is simply a test of php's e-mail ability. i am testing to see if i have it working right. if you got this in err, alert me by fwding it to 'removed my e-mail address from this spot'. thanx.

if not in err, then let me know if the following is what you entered: 
for a name: $user
for a pass: $pass

and your assigned "validation code" would be: $puid

ask me about the validation code. i should be logging it

-josh";

mail($email, $subject, $body, $header);

?><html><head><title>test</title></head><body><p>thanx for using the test. hit back to go back and test again</p></body></html><?php

}else{ // make the form

?><html><head><title>test of e-mail</title></head>
<body><center><p>testing of e-mail ability of php</p>
<form name="emailtest" method="POST" <?php echo "action="$_SERVER[PHP_SELF]""; ?> >
<input type="hidden" name="puid" <?php echo "value="$uid""; ?> >
<input type="hidden" name="done" value="test">
<table><tr><td>name</td><td><input type="text" name="un"></td></tr>
<tr><td>email</td><td><input type="test" name="email"></td></tr>
<tr><td>pass</td><td><input type="password" name="pass"></td></tr>
<tr><td><input type="submit" value="test me!"></td><td><input type="reset" value="clear me!"></td></tr>
</table></form></center></body></html><?php

}

?>

Posted: Sat Jun 07, 2003 12:15 am
by nielsene
Try

Code: Select all

$header="bcc: $bcc1\r\n";
I beleive the headers are not read unless that specific whitespace is there.

Posted: Sat Jun 07, 2003 9:48 am
by m3rajk
i'm working on linux.

the book said that's only used to seperate on windows and the oreilly cookbook said specificallyto leave it off the final one.

\r\n is windows, all others \n


i'll try with \n and get back to you.

Posted: Sat Jun 07, 2003 10:02 am
by m3rajk
i could have sworn this says it's linux: http://people.brandeis.edu/~m3rajk/JMT/ ... thingy.php

1 through 4 send. 1 doesn't try to bcc. the rest... 4 is the only one after i found out that it wasn't sending to the user submitted e-mail address.
http://people.brandeis.edu/~m3rajk/JMT/ ... est/email/

5 and 6 send, but like 4, they ignore the bcc. 5 is the same as 4 with the exception thathte line

Code: Select all

$header="bcc: $bcc1";
is

Code: Select all

$header="bcc: $bcc1\n";
and 6 has it as

Code: Select all

$header="bcc: $bcc1\r\n";

Posted: Sat Jun 07, 2003 10:12 am
by m3rajk
sorry. i just found out hotmail was trashing all the bccs. and that i HAVE been getting them since revission 4, not before that

version of php

Posted: Sat Jun 07, 2003 2:26 pm
by phpScott
I seem to remeber reading some where that it the BCC function is only avialable in php after version 4.2 I think. I tried to find the article agian so you might want to do a bit of research on it to find out about it.
I know that it is an issue on one of the servers I use because they are running a old version of php and it doesn't support the bcc header.

phpScott