Forum Moderators: coopster

Message Too Old, No Replies

email question

         

spritch2

12:54 am on Oct 26, 2004 (gmt 0)

10+ Year Member



i'm currently learning php using the book php and mysql web development 2nd edition, just finished the chapter building an email client and during testing sent out a couple of emails, the email to my hotmail account was fine but when sending an email to my outlook, i still received it but also got the following message:

The original message was received at Tue, 26 Oct 2004 01:23:54 +0100 (BST)
from 213-xx-xx-xx.example.uk [213.xx.xx.xx]

----- The following addresses had permanent delivery errors -----
@example.uk
(expanded from: <>)

my smtp settings are set to my isp's mail server, is it something to do with microsoft's measures to combat spam?

sorry, i'd ask the authors but support for this book is non existent.

my function looks like this:

function send_message($to,$cc,$subject,$message){
//send one email via PHP
global $_SESSION;

if(!db_connect())return false;

$query="
select address from users
where username = '".$_SESSION['auth_user']."'
";

$result=mysql_query($query);

if(!$result)return false;
else if(mysql_num_rows($result)==0)return false;
else{
$other='From: '.mysql_result($result,0,'address')."\r\nCc: $cc";

if(mail($to,$subject,$message,$other))return true;
else return false;
}
}

spritch2

[edited by: jatar_k at 3:32 am (utc) on Oct. 26, 2004]
[edit reason] generalized ip's and emails [/edit]

spritch2

3:40 am on Oct 26, 2004 (gmt 0)

10+ Year Member



seems after a bit of messin when you take off the Cc part it stops the error message, must b formatted wrong?

$other='From: '.mysql_result($result,0,'address')."\r\nCc: $cc";

jatar_k

3:55 am on Oct 26, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I usually build my headers seperately and set up all values before I cat them in

$from = mysql_result($result,0,'address');
$other='From: '.$from . "\r\n";
$other.="Cc: $cc\r\n";

you also probably need the \r\n after the Cc:

I also try to remember to only use " instead of ' in my headers so that I don't inadvertently put single quotes around a \r\n which won't work. ;)

spritch2

10:56 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



yeah it seemed outlook 6 has a problem with a null additional header, ended up checking the header before building the string, works now in outlook and hotmail

$other='From: '.mysql_result($result,0,'address')."\r\n";
if($cc!='')$other.="Cc: ".$cc;

thanks