473,770 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem: No headers sent with mail()

Hi,

My hostingprovider just updated to PHP 4.4. Since that time I have problems
using the mail() function in PHP. I can't send headers anymore and my
provider don't know what's wrong.
Here's a sample script:

if (mail("xx*@xxx. com", "test mail", "This is a <B>test</B>!", "From:
yy*@yyy.com (yyy)\r\nConten t-type: text/html")) {
print "Sent";
}
else {
print "Not sent";
}
I receive this body-text on xx*@xxx.com:

Content-type: text/html
Message-Id: <20************ ************@xx x.xxx.com>
Date: Thu, 8 Sep 2005 09:40:02 +0200 (CEST)

This is a <B>test</B>!

Does anybody know what's going wrong?

Regards,
Juul
Sep 8 '05 #1
7 1384
I mean that the headers are not interpreted by the mailserver but printed
as plain text...

Juul

Op Thu, 8 Sep 2005 10:17:58 +0200 schreef Juul:
Content-type: text/html
Message-Id: <20************ ************@xx x.xxx.com>
Date: Thu, 8 Sep 2005 09:40:02 +0200 (CEST)

Sep 8 '05 #2
Juul wrote:
Hi,

My hostingprovider just updated to PHP 4.4. Since that time I have problems
using the mail() function in PHP. I can't send headers anymore and my
provider don't know what's wrong.
Here's a sample script:

if (mail("xx*@xxx. com", "test mail", "This is a <B>test</B>!", "From:
yy*@yyy.com (yyy)\r\nConten t-type: text/html")) {
print "Sent";
}
else {
print "Not sent";
}


Had this code worked before?

Try this modification

<?php

if (mail('t******* *@example.com', 'Test Mail', 'This is a
<b>test</b>','From: Who Dat <fr*******@exam ple.com>'."\nCo ntent-type:
text/html"))
print 'Sent';
else
print 'Not Sent';

?>

What struck me as a possible problem in your original code was the
'From:' sting. The format "yy*@yyy.co m (yyy)" doesn't look right. The
correct way is "Name <em***@address. here>"

Ken

Sep 8 '05 #3
Hi Ken,

The script worked fine till the provider updated PHP. You may use
xx*@xxx.com (xxx) as the From header, that shouldn't be a problem.

The real problem I found was the use of \r\n. I tried to use \n only and it
works fine!

Thank you for your help.

Juul
Sep 8 '05 #4
Hello,

on 09/08/2005 05:17 AM Juul said the following:
My hostingprovider just updated to PHP 4.4. Since that time I have problems
using the mail() function in PHP. I can't send headers anymore and my
provider don't know what's wrong.
Here's a sample script:

if (mail("xx*@xxx. com", "test mail", "This is a <B>test</B>!", "From:
yy*@yyy.com (yyy)\r\nConten t-type: text/html")) {
print "Sent";
}
else {
print "Not sent";
}
I receive this body-text on xx*@xxx.com:

Content-type: text/html
Message-Id: <20************ ************@xx x.xxx.com>
Date: Thu, 8 Sep 2005 09:40:02 +0200 (CEST)

This is a <B>test</B>!

Does anybody know what's going wrong?


Several things seem to be wrong. The line breaks may not be correct. You
should not sent HTML only messages as many mail systems like Hotmail may
simply discard your message. For sending properly compose HTML messages,
you should compose MIME multipart/alternative messaages that include the
HTML part and an alternative text part.

If you don't know how to do that, you may want to try this MIME message
class. Take a look at the test_simple_htm l_mail_message. php example:

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Sep 9 '05 #5
Juul wrote:
You may use xx*@xxx.com (xxx) as the From header, that shouldn't be a problem.
Because it gives the impression of working? Sorry, ain't gonna wash
in a technical forum.

I think Ken was right to be suspicious, because afaics

From: fo*@bar.invalid (foo)

is not allowed to be generated under RFC2822.

It is one of the two forms allowed by son-of-RFC1036 though, so you
might find it on Usenet, and that might be where your idea that it
'shouldn't be a problem' comes from.
The real problem I found was the use of \r\n. I tried to use \n only and it
works fine!


What you tried there, what the Manual calls 'a last resort', suggests
the real problem lies with your MTA.

--
Jock
Sep 9 '05 #6
John Dunlop <us*********@jo hn.dunlop.name> wrote:

Juul wrote:
You may use xx*@xxx.com (xxx) as the From header, that shouldn't be a problem.


Because it gives the impression of working? Sorry, ain't gonna wash
in a technical forum.

I think Ken was right to be suspicious, because afaics

From: fo*@bar.invalid (foo)

is not allowed to be generated under RFC2822.


No, this is specifically allowed by RFC2822, although new implementations
are discouraged from using it.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Sep 10 '05 #7
Tim Roberts wrote:
John Dunlop <us*********@jo hn.dunlop.name> wrote:
From: fo*@bar.invalid (foo)

is not allowed to be generated under RFC2822.


No, this is specifically allowed by RFC2822, although new implementations
are discouraged from using it.


from = "From:" mailbox-list CRLF
mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
mailbox = name-addr / addr-spec

It can't be a name-addr because there are no greater-/less-than
signs, so that leaves:

addr-spec = local-part "@" domain

No room for comments there.

--
Jock
Sep 10 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3134
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time getting a SMTP script running. While the Drupal feedback module and the new account creation works fine in terms of sending of mails, I am having some problems with the sending of password reminder emails. warning: Cannot modify header information -...
2
2272
by: MJ | last post by:
I use the following code to send mails using php usinf PEAR package. When I run this code from command line using the command "php automaticMail.php" the code works fine. But when i run this script from browser it give the error : Starting..... Error sending mail: (unable to connect to smtp server 10.110.8.212:25) End of Program I am not figure out how this could happen ??? Sam code runs from command line sending mails correctly but...
20
1744
by: Pete Marsh | last post by:
Wondering if anyone can see an error with this script. I get a server configuration error. THat could mean a module is not being loaded, but maybe there's a syntax error here, can anyone spot it? Thanks <? Error_Reporting(E_ALL & ~E_NOTICE); $subject="from ".$_REQUEST ; $headers= "From: ".$_REQUEST ."\n"; $headers.='Content-type: text/html; charset=iso-8859-1';
1
3497
by: krishan123456 | last post by:
i have tried to send email with attached doc file but when i receive the mail i find the attached file in encoded text instead of actuall attachment.the code that i used to send an email is given below. function SendMail123($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles){ $OB="----=_OuterBoundary_000"; $IB="----=_InnerBoundery_001"; $Html=$Html?$Html:preg_replace("/\n/","{br}",$Text) or die("neither text nor...
1
2877
by: the_ricka | last post by:
Hi all, I'm fairly new to python, but very excited about it's potential. I'm trying to write a simple program that will accept input from a command line and send email. The parameters I used on the command line are for From address, To addresses, Subject and Body. For the body, I thought it would be better to read the input from a file so I could allow someone to nicely format the body with newlines in a text editor and just read it...
3
1477
by: swethak | last post by:
hi, i run the below code i got the below error when i run in my local system.And i placed same program in website it works fine.plz tell that what's the mistake in that. <?php $to ="aa@gmail.com"; $subject = "Site Registration Confirmation"; $message = '<html>
3
1722
by: swethak | last post by:
Hi, i placed the php in windows server 2003 manually , set the path in Environmental variables , and place the php.ini file in windows. Now php works fine in my server sytem.When i write the mail sending code and run that program mail didn't sent. in my php.ini file consists the smtp=localhost smtp_port=25 sendmail_from=me@localhost.com In my smtp settings: Internet Information Services->righclick on default virtual smtp...
0
1573
Dormilich
by: Dormilich | last post by:
this is a follow-up thread to this one. http://bytes.com/topic/html-css/answers/863662-form-not-submitted-sometimes I figured out that the mail sending class triggers the described error. unfortunately, no error message is given by the system. <?php class Mail_Tabelle extends Mail_DB { protected $description = false; const TBL_HEAD = ' <thead>
2
1851
by: urbanedge | last post by:
I've uploaded a site to a new server and now the headers in the mail function are not working to send the required email response. This is a newly acquired site and my php knowledge is at the beginner level. I've managed to list the headers that are being sent but I can't seem to find where or why the email won't work. I'd really appreciate some help checking to see if there is an error in one of the header lines or perhaps the redirection. ...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.