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

User receives a blank email. Why?

the mail() function

Moderators: macek, egami, gesf

User receives a blank email. Why?

Postby simplyroberto » Wed Jul 06, 2005 5:27 am

Please help!

In my website I send a welcome email to new members in html format. To do this I use the mail() function within a function I have created myself (see below). This fuction has been tested with all major mail programs and works just fine, but a particular user came back to me saying that he's received a blank email (his email address ends in @free.fr). I've sent the email again, but the same problem occured. Does anyone know what the cause could be?

Here's the function I have created to send html emails (arguments are self-explanatory):

function html_mail ($from_addr, $from_name, $to, $subject, $html_msg)
{
$html_msg = '
<html>
<head>
<title>'.$subject.'</title>
</head>
<body>'
.$html_msg.'
</body>
</html>
';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: ".$from_name." <".$from_addr.">";
return(mail($to, $subject, $html_msg, $headers));
}


Please help!!
Thank you

Roberto
simplyroberto
New php-forum User
New php-forum User
 
Posts: 14
Joined: Fri Apr 15, 2005 6:53 am

Postby gesf » Wed Jul 06, 2005 8:13 am

Amazing...! In my webmail client (horde), my messages come blank too and i don't know why.
First i thought it was because of my headers, but no...!

hunn simplyroberto... i start thinking it's not our problem, but those email clients :)
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Re: User receives a blank email. Why?

Postby WiZARD » Fri Jul 08, 2005 1:28 am

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: ".$from_name." <".$from_addr.">";
$headers .= "Subject: ".$subject." <".$sabject.">";

Some mail agent work with antispam program.
Add encoding and subject. maybe it's help.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby gesf » Fri Jul 08, 2005 2:17 am

Thanks Wiz! Will try that!
Yep.. my server is sending some stupid and never-ending antispam data.
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby WiZARD » Fri Jul 08, 2005 2:35 am

gesf wrote:Thanks Wiz! Will try that!
Yep.. my server is sending some stupid and never-ending antispam data.

Welcomen zum!
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby gesf » Fri Jul 08, 2005 3:08 am

Yeh... it's something aroung that!
Need to do some tricks yet... problems with the Content-Type...

Thanks Wiz :D
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Alexej Kubarev » Fri Jul 08, 2005 3:51 am

well its pretty stupid to leave out some headers: hehe.
Just one more way of showing how some programmers are really lazy :)

hehe
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby gesf » Fri Jul 08, 2005 3:59 am

Offended! Buáááááhhhhhhhhhhhhhhhhhhhh!
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Alexej Kubarev » Fri Jul 08, 2005 4:06 am

haha gesf :)
it was nothing personal.. its just that i notice that all the time... i had the same problem before as well. took about 6 month to completely remove that bad habbit :)
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby gesf » Fri Jul 08, 2005 4:23 am

Don't worry! Actually that phrase fits me good, 'cause i'll always making the same stupid and unacceptable mistakes :)
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby simplyroberto » Wed Jul 13, 2005 7:31 am

Thanks Wizard,

I've added the 2 headers as suggested but unfortunately the user still receives a blank email!

Roberto
simplyroberto
New php-forum User
New php-forum User
 
Posts: 14
Joined: Fri Apr 15, 2005 6:53 am

Postby Alexej Kubarev » Wed Jul 13, 2005 8:10 am

please give us an updated version of your code
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby simplyroberto » Wed Jul 13, 2005 2:58 pm

Hi Alexei,

Thanks for getting back to me. Please see below the function I use to send emails. Another problem I get is that the email is often marked as SPAM, no matter how simple the $html_msg is. So I believe it doesn't depend on the content of the email.
Here's the function:


function html_mail ($from_addr, $from_name, $to, $subject, $html_msg, $return_path = '')
{
// $return_path is optional

$html_msg = '
<html>
<head>
<title>'.$subject.'</title>
</head>
<body>'
.$html_msg.'
</body>
</html>
';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
if ($return_path)
$headers .= "Return-Path: <".$return_path.">\n";
$headers .= "From: ".$from_name." <".$from_addr.">";
return(mail($to, $subject, $html_msg, $headers));
}


I have also tried some small variations of it; for instance I've added the Subject header and I have also tried to replace \n with \r\n (which in turn gives other problem), but to no avail. It really bugs me, because many new members of my website cannot basically verify their email address!

Please help!!! :?
Roberto
simplyroberto
New php-forum User
New php-forum User
 
Posts: 14
Joined: Fri Apr 15, 2005 6:53 am

Postby ruturajv » Thu Jul 14, 2005 8:16 pm

try sending that mail (using same code ) to yourself... see if u get an empty mail.

and sending a text/plain email message, see if the Client is good enough.. to atleast understand that...
Actually its always good to send 2 formats of email.. 1 HTML one and other text/plain...
use phpmailer quite useful.
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

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