473,395 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why can't I send a mail with PHP

I can't send a mail with the following mail header:
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: \"User\" <us**@inter.net>\n";

Therefore $headers is set to (echo $header;)
MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: "User"
<us**@inter.net>

The mail has not been delivered and my PHP server says:
[24-Nov-2005 00:37:19] PHP Warning: mail() [<a
href='function.mail'>function.mail</a>]: SMTP server response: 501 5.5.4
Invalid Address in C:\PHP\file.php on line 132
If I use
$headers .= "From: us**@inter.net\n";
instead of
$headers .= "From: \"User\" &lt;us**@inter.net&gt;\n";
is works perfect.

What's wrong?
Stefan
Nov 24 '05 #1
8 3844
SC
Don't use &lt; and &gt;. Use the actual characters < and >.
"Stefan Mueller" <se**************@yahoo.com> wrote in message
news:dm***********@news.imp.ch...
I can't send a mail with the following mail header:
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: \"User\" &lt;us**@inter.net&gt;\n";

Therefore $headers is set to (echo $header;)
MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From:
"User" <us**@inter.net>

The mail has not been delivered and my PHP server says:
[24-Nov-2005 00:37:19] PHP Warning: mail() [<a
href='function.mail'>function.mail</a>]: SMTP server response: 501 5.5.4
Invalid Address in C:\PHP\file.php on line 132
If I use
$headers .= "From: us**@inter.net\n";
instead of
$headers .= "From: \"User\" &lt;us**@inter.net&gt;\n";
is works perfect.

What's wrong?
Stefan

Nov 24 '05 #2
If I use
$headers .= "From: us**@inter.net\n";
instead of
$headers .= "From: \"User\" &lt;us**@inter.net&gt;\n";
is works perfect.

What's wrong?
Stefan


I tried the following versions before
$headers .= "From: \"User\" <us**@inter.net>";
or
$headers .= "From: 'User' <us**@inter.net>";
or
$headers .= "From: User <us**@inter.net>";
or
$headers .= 'From: "User" <us**@inter.net>';

However, no version works.

Does someone see what's wrong?
Stefan
Nov 24 '05 #3
>>> If I use
$headers .= "From: us**@inter.net\n";
instead of
$headers .= "From: \"User\" &lt;us**@inter.net&gt;\n";
is works perfect.

What's wrong?
Stefan


I tried the following versions before
$headers .= "From: \"User\" <us**@inter.net>";
or
$headers .= "From: 'User' <us**@inter.net>";
or
$headers .= "From: User <us**@inter.net>";
or
$headers .= 'From: "User" <us**@inter.net>';

However, no version works.

Does someone see what's wrong?


If you don't put a newline at the end of the header, another header
is going to wind up on the same line, and it will break things:

From: User <us**@inter.net>Subject: this is not spam

Also, if the envelope-from and/or destination address is not valid,
the mail won't go either, regardless of headers. No HTML allowed
in those, either.

Gordon L. Burditt
Nov 24 '05 #4
SC
Here's an example of proper headers:

$mail_headers = 'From: "Sender Name" <se****@domain.com>' . "\n"
.. 'MIME-Version: 1.0' . "\n"
.. 'Message-ID: <' . md5(uniqid(time())) . '@domain.com>' . "\n"
.. 'Content-Type: text/html; charset="iso-8859-1"' . "\n"
.. 'Content-Transfer-Encoding: 8bit' . "\n"
.. 'Importance: Normal' . "\n";

"Stefan Mueller" <se**************@yahoo.com> wrote in message
news:dm***********@news.imp.ch...
If I use
$headers .= "From: us**@inter.net\n";
instead of
$headers .= "From: \"User\" &lt;us**@inter.net&gt;\n";
is works perfect.

What's wrong?
Stefan


I tried the following versions before
$headers .= "From: \"User\" <us**@inter.net>";
or
$headers .= "From: 'User' <us**@inter.net>";
or
$headers .= "From: User <us**@inter.net>";
or
$headers .= 'From: "User" <us**@inter.net>';

However, no version works.

Does someone see what's wrong?
Stefan

Nov 24 '05 #5
> $mail_headers = 'From: "Sender Name" <se****@domain.com>' . "\n"
. 'MIME-Version: 1.0' . "\n"
. 'Message-ID: <' . md5(uniqid(time())) . '@domain.com>' . "\n"
. 'Content-Type: text/html; charset="iso-8859-1"' . "\n"
. 'Content-Transfer-Encoding: 8bit' . "\n"
. 'Importance: Normal' . "\n";


It's really unbelievable. I've tried so many headers and
'From: "Sender Name" <se****@domain.com>'
never works.
That same with your header. PHP says:
[24-Nov-2005 08:00:05] PHP Warning: mail() [<a
href='function.mail'>function.mail</a>]: SMTP server response: 501 5.5.4
Invalid Address in C:\PHP\file.php on line 132

If I modify your header to
$jt = 'From: se****@domain.com' . "\n"
. 'MIME-Version: 1.0' . "\n"
. 'Message-ID: <' . md5(uniqid(time())) . '@domain.com>' . "\n"
. 'Content-Type: text/html; charset="iso-8859-1"' . "\n"
. 'Content-Transfer-Encoding: 8bit' . "\n"
. 'Importance: Normal' . "\n";
it works perfect again.

But why is
'From: "Sender Name" <se****@domain.com>'
never working.

I'm trying since several days and I'm really loosing hope.
Stefan

Nov 24 '05 #6
i don't really have time to analyze your code. I send you my email
script. and my code
is completely working. i hope it helps for you.
************************************************** ***
$to = $remail; // fill your email address here
$subject = "Invitation to Patra Friends"; // fill your subject here..
//and the message here..
$message = "

Kami mengundang Anda untuk menjadi member
jaringan alumni Himpunan Teknik Perminyakan ITB

silahkan klik
http://alumni.tm.itb.ac.id/registrasi.php?p=$passp&q=$pass2
untuk melakukan registrasi

Terimakasih
Admin Patra -- ad***@alumni.tm.itb.ac.id

";

$headers .= 'From: *Patra Admin <ad***@alumni.tm.itb.ac.id>' .
"\r\n";// this one is to indicate the header..

mail($to, $subject, $message, $headers);// this is the command

Nov 24 '05 #7
SC
After a little checking I found that many people report that PHP for Windows
does not support the "from" header being anything other than just the e-mail
address.

You apparently can't send a "from" header like 'From: "Sender Name"
<se****@domain.com' under PHP for Windows. This only seems to work with
non-Windows installations of PHP.
"Stefan Mueller" <se**************@yahoo.com> wrote in message
news:dm***********@news.imp.ch...
It's really unbelievable. I've tried so many headers and
'From: "Sender Name" <se****@domain.com>'
never works.
That same with your header. PHP says:
[24-Nov-2005 08:00:05] PHP Warning: mail() [<a
href='function.mail'>function.mail</a>]: SMTP server response: 501 5.5.4
Invalid Address in C:\PHP\file.php on line 132

Nov 24 '05 #8
"SC" <no*****@thank.you> wrote in message
news:jv*************@news.uswest.net...
After a little checking I found that many people report that PHP for
Windows does not support the "from" header being anything other than just
the e-mail address.

You apparently can't send a "from" header like 'From: "Sender Name"
<se****@domain.com' under PHP for Windows. This only seems to work with
non-Windows installations of PHP.


Wow, that's very bad. But now I know why I could read so many PHP mail pages
and it still doesn't work because it's not implemented in my PHP version.
That's a really very bad news. But now I know that I can stop testing and
testing and testing ...

Thanks a lot for telling me that.
I was really loosing the hope.
Stefan
Nov 24 '05 #9

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

Similar topics

6
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I...
6
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of...
4
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP...
2
by: kmbarz | last post by:
I'm trying to expand my horizons here by working through an ASP.Net book. When I do the example that uses: Line 55: Mail.From = "feedback@graymad.com" Line 56: ...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
10
by: Dennis | last post by:
I am trying to send an e-mail using one of the examples I got on this group as follows: (both toemail and myemail are valid e-mail addreses. 'System.Web.Mail' (requires reference to...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
9
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
7
by: Rob Dob | last post by:
The following code is giving me a timeout problem., no matter what I do I can't send a piece of mail using .net2.0 System.Net.Mail.SmtpClient via port 465 and using ssl, if however I try using...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.