Anyone please help me?

the mail() function

Moderators: macek, egami, gesf

doug145
New php-forum User
New php-forum User
Posts: 3
Joined: Sun Dec 25, 2011 4:24 pm

Anyone please help me?

Postby doug145 » Thu Dec 29, 2011 9:34 am

Please tell me why this code I have below sends an email to the user's email that they entered on a form which is the $newemail, but it will not send an email to the second hardcoded email address which is admin@yahoo.com? I badly need to know:

$mailto = $newemail;
$mailto .= ",";
$mailto .= "admin@yahoo.com";
$subject = 'Your new account';
$message = 'A new account has been setup. We look forward to serving your investment needs.';
$message .= "\r\nUsername: ";
$message .= $newusername;
$message .= "\r\n";
$header = "From: admin@yahoo.com"."\r\n";
$header .= "Reply-To: admin@yahoo.com"."\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: PHP v".phpversion();

mail ($mailto, $subject, $body, $headers);

User avatar
bigjoe11a
New php-forum User
New php-forum User
Posts: 128
Joined: Wed Aug 31, 2011 3:55 am
Location: USA
Contact:

Re: Anyone please help me?

Postby bigjoe11a » Sun Jan 29, 2012 6:55 pm

Ok, for one thing you can't run the code like this. Try using a function instead.


Code: Select all


function SendMsg($to)

$mailto = $to;
$subject = 'Your new account';
$message = 'A new account has been setup. We look forward to serving your investment needs.';
$message .= "\r\nUsername: ";
$message .= $newusername;
$message .= "\r\n";
$header = "From: admin@yahoo.com"."\r\n";
$header .= "Reply-To: admin@yahoo.com"."\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: PHP v".phpversion();

mail ($mailto, $subject, $body, $headers);



To use this function you would do some thing this.

Code: Select all

SendMsg("admin@yahoo.com");
// or send another
SendMsg("admin@google.com");


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest

cron