Email Issue in PHP Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
charman
Forum Newbie
Posts: 2
Joined: Mon Sep 18, 2006 5:50 pm

Email Issue in PHP Code

Post 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]
arkady
Forum Newbie
Posts: 23
Joined: Sun Sep 17, 2006 9:34 pm

Post by arkady »

Code: Select all

$recipients = '$email';
will produce

Code: Select all

echo $recipients;
> $email
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply