24, July 2008

mail header issue (am i going crazie?!) - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: mail header issue (am i going crazie?!)
« previous next »
Pages: [1] Print

Author Topic: mail header issue (am i going crazie?!)  (Read 959 times)
What a dork
*
Posts: 17
110 credits
Members referred : 0


« on: Aug 09, 2006, 02:53:27 AM »

I get an error dealing with this line:
$header = "From: \" " . $this->webmaster_name . " \" <".$this->webmaster_mail.">\r\n";  (in the access_user_class.php)

When I replace that line with this:
$header = "From: mymail@hotmail.com\r\n";
It works like a charm. How come only I have trouble with this line?

The variables are all fine... it seems that after the less-than-sign (quote: &lt".$this-) the whole string turns into an html tag?  - I use WAMP 5 , PHP version 5...

I cannot believe I am the only one with this problem...
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 09, 2006, 08:45:06 AM »

I get an error dealing with this line:
$header = "From: \" " . $this->webmaster_name . " \" <".$this->webmaster_mail.">\r\n";  (in the access_user_class.php)

When I replace that line with this:
$header = "From: mymail@hotmail.com\r\n";
It works like a charm. How come only I have trouble with this line?

The variables are all fine... it seems that after the less-than-sign (quote: &lt".$this-) the whole string turns into an html tag?  - I use WAMP 5 , PHP version 5...

I cannot believe I am the only one with this problem...


please post the code and you form (or the url to the form)


Last blog : 4th of July Lottery from TemplateMonster.com
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #2 on: Aug 09, 2006, 09:12:36 PM »

When I use this function(lines 458-475 in access_user_class.php):
function send_mail($mail_address, $msg = 29, $subj = 28, $send_admin = false) {
   $header = "From: \"".$this->webmaster_name."\" <".$this->webmaster_mail.">\r\n";

   $header = "From: ".$this->webmaster_mail."\r\n";  //my only modification

   if ($send_admin) $header .= "Bcc: ".ADMIN_MAIL."\r\n";
   $header .= "MIME-Version: 1.0\r\n";
   $header .= "Mailer: Olaf's mail script version 1.11\r\n";
   $header .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
   $header .= "Content-Transfer-Encoding: 7bit\r\n";
   $subject = $this->messages($subj);
   $body = $this->messages($msg);
   if (mail($mail_address, $subject, $body, $header)) {
      return true;
   } else {
      return false;
   }
}

And run http://localhost/classes/register.php Visit through proxy it results in a HTML webpage:
<p><b>Please check your e-mail and follow the instructions.</b></p>   etc. etc.
Everything worked fine!!!

But when I use this function(lines 458-472 in access_user_class.php),
minus my line:
function send_mail($mail_address, $msg = 29, $subj = 28, $send_admin = false) {
   $header = "From: \"".$this->webmaster_name."\" <".$this->webmaster_mail.">\r\n";
   if ($send_admin) $header .= "Bcc: ".ADMIN_MAIL."\r\n";
   $header .= "MIME-Version: 1.0\r\n";
   $header .= "Mailer: Olaf's mail script version 1.11\r\n";
   $header .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
   $header .= "Content-Transfer-Encoding: 7bit\r\n";
   $subject = $this->messages($subj);
   $body = $this->messages($msg);
   if (mail($mail_address, $subject, $body, $header)) {
      return true;
   } else {
      return false;
   }
}

And run http://localhost/classes/register.php Visit through proxy again, I get this SMTP error message (smtp: mail.chello.nl):
Warning:  mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 550 Sender address is invalid in C:\wamp\www\classes\access_user\access_user_class.php on line 467

Now I already did some debugging and my temporary conclusion is:
<"  is interpreted as a tag outside the string in line 459 of the function.

I use PHP 5.1.4, Apache 2.5.55 on Windows XP SP2, MySQL 5.0.21

Can I replace the < symbol with str_replace()? Hope you have some insight...
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 09, 2006, 10:35:28 PM »

this not a problem with the script, try the same code at your remote host.

(the problem is that Chello blocks smtp calls like the most other providers)

or try to send some mail with simple scripts and play with you php settings...


Last blog : 4th of July Lottery from TemplateMonster.com
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #4 on: Aug 10, 2006, 08:37:28 AM »

No, chello smtp does relay my mail really well (no authentication needed).
Using this line:
  $header = "From: ".$this->webmaster_mail."\r\n";  //my only modification
Puts out: From: yourname@yourdomain.com
And works perfect! Before I posted yesterday I tested it to be 100% sure and the mails arrive every time.

Using this line:
   $header = "From: \"".$this->webmaster_name."\" <".$this->webmaster_mail.">\r\n";
Puts out: From: "The webmaster"
And that is why I get: SMTP server response: 550 Sender address is invalid
The question is how do I get: From: "The webmaster" <yourname@yourdomain.com>
Instead of only: From: "The webmaster"

« Last Edit: Aug 10, 2006, 08:53:44 AM by scooter »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Aug 10, 2006, 09:07:55 AM »

The full "from" header is the name and the email address, I think in your case there is a diifferent problem (I saw before):

Code:
<?php
mail
("nobody@example.com""the subject"$message,
    
"From: webmaster@{$_SERVER['SERVER_NAME']}""-fwebmaster@{$_SERVER['SERVER_NAME']}");
?>


note the "-f" and the return path...I don't think it's about the quotes


Last blog : 4th of July Lottery from TemplateMonster.com
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #6 on: Aug 11, 2006, 01:02:55 AM »

Thanks for the example Olaf. It worked perfectly (mail arrived in my mailbox). I had to replace webmaster@localhost with a real e-mail address though.

I know the proplem is and remains this line:
$header = "From: \"".$this->webmaster_name."\" <".$this->webmaster_mail.">\r\n";

And I know the output of this line is:
From: "The webmaster"

I know my PHP setup interprets this <" as a tag and escapes the string.
When I change it to < " than it doesn't escape the string, but the e-mail address becomes meaningless.

I am clueless how I can solve that and why others don't seem to have it?
« Last Edit: Aug 11, 2006, 01:07:10 AM by scooter »
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #7 on: Aug 11, 2006, 01:34:47 AM »

Olaf, I just had an idea...

Apparently the Chello smtp is perfectly willing to relay your mail when you use this convention: From: yourmail@yourdomain.com

However when you use this (more common) convention:
From:  "Any name" <yourmail@yourdomain.com>

mail.chello(.nl) does NOT like it. You were right when you said:"try the same code at your remote host."

The only thing I don't know is why chello smtp works this way, specially concidering that chello doen't ask for server (SMTP) verification???

Thanks for your quick help Olaf.  I am a newby to PHP and web apps (I am a VBA junkie) but I hope to return the favor some time when I write my first class for some application.

-Scooter
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Aug 11, 2006, 01:36:39 AM »

Thanks for the example Olaf. It worked perfectly (mail arrived in my mailbox). I had to replace webmaster@localhost with a real e-mail address though.

I know the proplem is and remains this line:
$header = "From: \"".$this->webmaster_name."\" <".$this->webmaster_mail.">\r\n";

And I know the output of this line is:
From: "The webmaster"

I know my PHP setup interprets this <" as a tag and escapes the string.
When I change it to < " than it doesn't escape the string, but the e-mail address becomes meaningless.

I am clueless how I can solve that and why others don't seem to have it?


do you tried this kind of line:

$header = "From: ".$this->webmaster_name." <".$this->webmaster_mail.">\r\n";

sending mails is sometimes reallt strange... I think that I will write a port for access_user to use a bigger e-mailer project with more mail functions (sending mail via smtp etc)


Last blog : 4th of July Lottery from TemplateMonster.com
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Aug 11, 2006, 01:38:28 AM »

Quote
The only thing I don't know is why chello smtp works this way, specially concidering that chello doen't ask for server (SMTP) verification???

I think that is because you're on the chello network, at the demon dsl network you need to enter the user name...


Last blog : 4th of July Lottery from TemplateMonster.com
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #10 on: Aug 11, 2006, 04:03:47 PM »

I tried it: $header = "From: ".$this->webmaster_name." <".$this->webmaster_mail.">\r\n";
Results in: Warning: mail() [function.mail]: SMTP server response: 550 Sender address is missing a domain
Apperantly chello interpretes The webmaster as the from e-mail address. 

The only thing that works with chello is this line: $header = "From: ".$this->webmaster_mail."\r\n";

More mail functions sounds great. Personaly I am planning on slightly rewriting your Access_user class so that your e-mail address is your login. For some smaller applications user tend to prefer that so they don't have to remember their username for every site (MSN messenger uses this convention, come to think of it).
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Aug 11, 2006, 05:20:29 PM »

Quote
More mail functions sounds great. Personaly I am planning on slightly rewriting your Access_user class so that your e-mail address is your login. For some smaller applications user tend to prefer that so they don't have to remember their username for every site (MSN messenger uses this convention, come to think of it).

That's an good idea but write an extension because only a few methods need be rewritten for this. This way you're able to use updated versions from the original class.


Last blog : 4th of July Lottery from TemplateMonster.com
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3587
Tags : php html mysql apache email Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: mail header issue (am i going crazie?!)
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 24, 2008, 11:28:13 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.712
Total Topics: 7.376
Total Members: 3.706
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: FortuneBeach

28 Guests, 3 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.