Page 1 of 1

Email Issue in PHP Code

Posted: Mon Sep 18, 2006 6:15 pm
by charman
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The problem I have come across is with this registration page I have been working on. It appears that the registration email is not being sent out.  Intially it was only sending to any address outside of aol.com or aim.com addresses.  I thought I had isolated the issue to underscores and alpahnumeric email addresses. But then it just all of a sudden completely stopped working and wouldnt send to anyone.  Can someone take a gander at the code below. Has anyone heard of anything like this I am at the end of my rope I have tried everything I can think of.  

Thank you all for your help

Code: Select all

include('Mail.php');

$recipients = '$email';

$headers['From']    = 'abcd@abcd.com'; 
$headers['To']      = $email;
$headers['Subject'] = abc activation required...';
$params['sendmail_path'] = '/usr/lib/sendmail -t -i';

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('sendmail', $params);

$mail_object->send($recipients, $headers, $body);

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Sep 18, 2006 6:27 pm
by arkady

Code: Select all

$recipients = '$email';
will produce

Code: Select all

echo $recipients;
> $email

Posted: Mon Sep 18, 2006 6:34 pm
by s.dot
Parse error

Code: Select all

$headers['Subject'] = abc activation required...';
should be

Code: Select all

$headers['Subject'] = 'abc activation required...';
Email not being sent? Inclose it in an if/else.

Code: Select all

if($mail_obj->send())
{
   echo 'mail sent.';
} else
{
   echo 'mail not sent!';
}
Also with your parse error, it seems you don't have error reporting turned on.

Code: Select all

ini_set("display_errors","On");
error_reporting(E_ALL)

Posted: Mon Sep 18, 2006 6:44 pm
by RobertGonzalez
Changing the display_errors directive at runtime would not have changed this error display.

However, if you are developing locally, you should be developing with display_errors On in your php.ini, so that things like this will scream at you what is happening.