Jump to content

PHP Mail() Function


vamsee

Recommended Posts

Hello,

I have been trying to send an email to every email address in the table. The email goes fine without any hassles. But iam encountering a strange problem. The header variables are getting displayed in the email even though I dont echo them. Can some one please help me with this. I will send you the code so that you can tell me what I folly I am comitting and also the email that I recieved.

The code to send email :
[code]
$sql_email= "SELECT emailAddress  FROM emails ORDER BY contactID";

if ($result_email = mysql_query($sql_email))
  {
  while ($dataRow_email = mysql_fetch_object($result_email))
{
//################ SEND EMAIL (START) ####################
   
  $to      = "$dataRow_email->emailAddress";
  $subject = "RC - News Paper Service ";
  $message = "
<table width='95%' border='0' cellspacing='2' cellpadding='2'>
  <tr>
    <td>Dear User,</td>
  </tr>
  <tr>
    <td>The following press clippings were uploaded today  :</td>
  </tr>
  <tr>
    <td>$mytitle</td>
  </tr>
  <tr>
    <td>To view the full articles login in to www.rsunit.com/?page=press at the press clipping service.</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Thank you,</td>
  </tr>
  <tr>
    <td>Regards,</td>
  </tr>
  <tr>
    <td>Research Center, Cyprus College </td>
  </tr>
  <tr>
    <td>www.rsunit.com</td>
  </tr>
</table>
";
$headers .= 'From: Research Center <[email protected]>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-7' . "\r\n";

mail($to, $subject, $message, $headers);


//################ SEND EMAIL (END) #################### 
            }
}
[/code]


The  email is like this

[code]From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7 From: Research Center Content-type: text/html; charset=iso-8859-7

Dear User,

The following press clippings were uploaded today :

Δέκα δράσεις για καινοτομία και ανταγωνιστικότητα||Κοινή πλατφόρμα: Ορίζοντες αλλά και ιδιαίτερη προσοχή||

To view the full articles login in to www.rsunit.com/?page=press at the press clipping service.



Thank you,

Regards,

Research Center, Cyprus College

www.rsunit.com[/code]

Thank you in advance please help me out with this

Link to comment
https://forums.phpfreaks.com/topic/25674-php-mail-function/
Share on other sites

You're sending an email in the HTML format and you're starting off without defining the HTML section...
[code]<html>
<head>
  <title>Email from me</title>
</head>
<body>
...insert your code here...
</body>
</html>[/code]
Not sure if that is the reason its showing the headers or not, give it a go and see if it fixes the problem.
Link to comment
https://forums.phpfreaks.com/topic/25674-php-mail-function/#findComment-117178
Share on other sites

You will find that headers are being attached by the mail server that your are routing your SMTP traffic through. This is why you cannot change the return address header to something other than what is written in your php.ini within your code.

Also as I have just noticed you have started your headers variables as

$headers .=

Surely for the first instance it would be $headers =

Plus your quotes may be throwing it off too, why use singles when you use doubles at the end?

[code]
$headers = "From: Research Center <[email protected]>"."\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-7"."\r\n";
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25674-php-mail-function/#findComment-117211
Share on other sites

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.