Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail()

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Can anyone see any reasno why this code will not send?

mail("$email", $subject, $message,
"From: $adminemail\r\n"
."Reply-To: $adminemail\r\n"
."sendmail_path: /usr/lib/sendmail\r\n");


Thanks

Andy
 
I would try putting quotes around $subject and $message... like this:
Code:
mail("$email",
Code:
"
Code:
$subject
Code:
"
Code:
,
Code:
"
Code:
$message
Code:
"
Code:
,
     "From: $adminemail\r\n"
    ."Reply-To: $adminemail\r\n"
    ."sendmail_path: /usr/lib/sendmail\r\n");
-gerrygerry
Go To
 
Didn't work :( Is there any way to catch errors from sending the mail??? maybe an 'or die' ???

Thanks

Andy
 
it returns a value. 0 for error or 1 for success. if you get 1 and the mail does not arrive, can be of your SMTP. Then you need to remove the \r form the strings. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
How would i catch the error? Put it in something like $var = mail(); ????

Thanks


Andy
 
correct
and echo $var or print_r($var) mcvdmvs
-- "It never hurts to help" -- Eek the Cat
 
Erm...I'm using;

if ($debug) { echo "sending emails now..."; }
$mail = mail("$email", "$subject", "$message",
"From: $adminemail\r\n"
."Reply-To: $adminemail\r\n"
."sendmail_path: /usr/lib/sendmail\r\n");

if ($debug) { echo "\$mail - $mail"; }

However, 1 or 0 is not returned. Any more ideas?

Thanks

Andy
 
Do you have to use that sendmail path? Or will your script work without it? mcvdmvs
-- "It never hurts to help" -- Eek the Cat
 
Yes, or the SMTP server if you use windows. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
hello,
Try using this

$header .= "From: $adminemail\r\n" ;
$header .= "Reply-To: $adminemail\r\n" ;
$header .= "sendmail_path: /usr/lib/sendmail\r\n";

$test = mail("$email", $subject, $message,$header) ;

if(!test)
echo "error in sending mails";



also if ur using UNIX OS try removing the \r and seperate the headers only with \n.

hope that will help u.

Spookie






 
I think there is a bug in the mail() function ;) For some reason, when sending to non-redirected email account (i.e. my hotmail.com or tiscali.co.uk account) it gets sent fine. As soon as I send it through an account like ace-host.com (which redirects to my ticali.co.uk account) it just doesn't get through! Anyone else experienced this before?

Thanks

Andy
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top