Jump to content

php mail one works but the other doesnt


pgrevents

Recommended Posts

I have been having problems with this code for a couple of days. I have an activation email that gets sent to the user and one to me saying someone has registered. the one to me works fine. My host says that i have to use the -f command before the email address that its from. Here is my code that I am having problems with

<?php
$activation = $_GET['activation'];
$fname = $_GET['fname'];
$from_email = "[email protected]";
$from_name = "PGR Events";
$emaila = "[email protected]"; //senders e-mail adress
$email = $_GET['email']; //recipient
$mail_body = "
<html>
<body>
<p align=\"center\"><img src=\"http://www.pgrevents.co.uk/images/pgrlogo.png\" alt=\"PGR EVENTS\" width=\"395\" height=\"196\" /></p>
<p>Thank you ".$fname.",</p>
<p>You are now registered with PGR Events before you have access to this site you must first confirm your email address. You can do this by clicking the link below or copying and pasting the link into your browser.</p>
<p> </p>
<br /><p><a href=\"http://www.pgrevents.co.uk/?display=activate&code=".$activation ."\">CLICK HERE TO CONFIRM YOUR EMAIL ADDRESS</a></p>
<p> </p>
<p>if the above link does not work copy and paste the below link</p>
<p>http://www.pgrevents.co.uk/?display=activate&code=".$activation ."</p>
<p> </p>
<p>Thank you for your interest in PGR Events</p>
<p> </p>
<hr />
<p>**This is an Automatic Email**
The information in this email and attachments is confidential and  intended for the sole use of the addressee(s). Access, copying, disclosure or  re-use, in any way, of the information contained in this email and attachments  by anyone other than the addressee(s) is unauthorized. If you have received  this email in error, please return it to the sender and highlight the error.<br />
<br />
We accept no legal liability for the content of the message. Any opinions or  views presented are solely the responsibility of the author and do not  necessarily represent those of PGR Events
</body>
</html>
\n
"; //mail body
$subject = "Email Verification Code"; //subject
$user = "[email protected]";
$headers .= "To: \"".$fname."\" <\"".$email."\">\n";
$headers .= "MIME-Version: 1.0\n"; 
$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n"; //optional headerfields
mail("$subject", "$mail_body", "$headers", "From: $from_name", "[email protected]"); //mail command 
// the script above does not work

/// the below mail is the one that works note the -f$user command
mail("[email protected]", "New User Registered","New User Registered Code = $activation","From: $user", "-f$user" );
header('Location:http://www.pgrevents.co.uk/?display=registration&type=complete');
?>

 

 

does anyone have any ideas?

 

thanks in advance :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/155666-php-mail-one-works-but-the-other-doesnt/
Share on other sites

It is such a small error that it is barely noticable, but you had a "$" in the -f portion. Should be:

<?php
$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n"; //optional headerfields
mail("$subject", "$mail_body", "$headers", "From: $from_name", "[email protected]"); //mail command 
// the script above does not work
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.