Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

not the right "From" adress

the mail() function

Moderators: macek, egami, gesf

not the right "From" adress

Postby tranquillo » Fri Apr 09, 2004 2:05 pm

hi...

I'm trying to get a php mail script working, but it's nog going to good....

I looked around here for some sample code and foud a link to some site, don't remember wich, where I found some... I've changed it a bit, but it doesn't work... there were more "headers" first, but everyting in the header after "Content-type: text/html;" is printed out as text in the email... so in the email where the From: adress should be, theres the adress to the server, and at the top of the email theres the header text, including the "From:" thing...

so, what I want is the sender/reply adres to be in the right adress field and no additional text in the message...

I hope you understand my problem and I hope you know how to fix it...

here's the code:


Code: Select all
<?php

$myname = "test";
$myemail = "someguy@myplace.se";

$subject = "testar lite bara";

$message = "<HTML><body>";
$message .= "Hi ,<br><br>";
$message .="Ticket requires <font color='#999999'>your feedback</font>. If
         you could please contact us regarding the
         status<br>";
         $message .= "of your system it would be
         appreciated.<br>&Aring;
         &Ouml;<br>";
$message .= "<BR><BR><BR>Thank
         You,<br>";
$message .= "</body></html>";

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;";
$headers .= "From: ".$myemail."\r\n";

$email = "someguy@myplace.se";

$var = mail($email, $subject, $message,
$headers);

if($var)
 echo'det funkade';
else
   echo'det funkade INTE';
?>
[/quote][/code]
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

Postby gesf » Sat Apr 10, 2004 1:09 am

An error here:[php]<?
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;";
$headers .= "From: ".$myemail."\r\n";
?>[/php]This is right![php]<?
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;";
$headers .= "From: ".$myemail."\r\n";
?>[/php]

The rest seems to be fine!
I suggest you to use error_reporting() in your code, so you can see what´s wrong!
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby swirlee » Sat Apr 10, 2004 5:52 am

You're correct, gesf, that throws a notice, but his code still ought to work..
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby gesf » Sat Apr 10, 2004 8:58 am

Yeh my friend, but he have to test it and tell us what´s wrong :P
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby tranquillo » Sun Apr 11, 2004 8:14 am

thanks guys... it reduced the problem a litle bit...
I removed the "." and now the headers don't show in the message, but the replyadress is still not right... when I press reply, the adress is "mydomain.whatever@theWebHotelServer.whatever".
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

Postby tranquillo » Sun Apr 11, 2004 11:08 am

Hi again...

I've been fooling around with the headers some more and got the d***** mail to use the right reply adress...

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;";
$headers .= "From: ".$myemail."\r\n";
$headers .= "Reply-To: ".$myemail."\r\n";

what buggs me now is the "From:" header... it still doesn't show the right text... whatever the $myemail variable contains it still shows the domain name of the site in the email... and if I write

$headers .= "From: Something\r\n";

it still shows "From: mydomain.net".
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

Postby tranquillo » Wed Apr 21, 2004 9:51 am

Hi again guys...
now I'm confused... This is something that really buggs me when programming in any language: prolems that fix themselves and I don't have a clue why.

All I really did was add the error report thing... no errors were reported and the email looks just the way I want it.

anyways, thanks for the help!
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.