| | |
php e-mail problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
I have some simple php code. It worked fine on the old server, but now I am getting an error on the new server. Both former and present servers are Linux.
Here is my error message that I get from the mail server in an e-mail. Subject line is The e-mail addresses have been changed. The second address of the cc line is getting tossed out (mo@gmail.com). I'm not sure why. The recipient and the first cc address are being sent correctly. It worked on the last server. Any ideas? Thanks.
php Syntax (Toggle Plain Text)
<?php function ConfirmationEmail () { $from = "mo@abc.com"; $recipient = "bill@yahoo.com"; $cc1 = $from; $cc2 = "mo@gmail.com"; $subject = "Trial e-mail!"; $message = "This is a test!\n"; $headers = "From: " . $from . "\r\n" . "Cc: " . $cc1 . " " . $cc2; $success = mail($recipient,$subject,$message,$headers); if ($success) echo "<br>A confirmation e-mail was just sent to you.<br>"; else { echo "An attempt was made to send you an e-mail, "; echo "but it was unsuccessful. <br>"; } } ?>
Here is my error message that I get from the mail server in an e-mail. Subject line is
•
•
•
•
"Inbox: Mail failure - malformed recipient address"
•
•
•
•
A message that you sent contained one or more recipient addresses that were
incorrectly constructed:
mo@abc.com mo@gmail.com: malformed address: mo@gmail.com may not follow mo@abc.com
This address has been ignored. The other addresses in the message were
syntactically valid and have been passed on for an attempt at delivery.
0
#2 Nov 24th, 2008
i made an email class. try it and make sure that you have the headers formed correctly.
http://www.daniweb.com/forums/thread155761.html - Post
#12
then we will see if something is wrong the the server config.
http://www.daniweb.com/forums/thread155761.html - Post
#12
then we will see if something is wrong the the server config.
Last edited by kkeith29; Nov 24th, 2008 at 4:22 pm.
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
•
•
•
•
i made an email class. try it and make sure that you have the headers formed correctly.
http://www.daniweb.com/forums/thread155761.html - Post
#12
then we will see if something is wrong the the server config.
As far as my problem goes, I did an experiment and if I change line 10 from:
PHP Syntax (Toggle Plain Text)
$headers = "From: " . $from . "\r\n" . "Cc: " . $cc1 . " " . $cc2;
to
$headers = "From: " . $from . "\r\n" . "Cc: " . $cc1 . ", " . $cc2;Note the added comma above. It seems to work better. Are you supposed to separate the addresses with a comma? I'll get back to you regarding your e-mail class. That could have great potential. Thank you!
•
•
Join Date: Jan 2008
Posts: 141
Reputation:
Solved Threads: 19
Hi,
This may be way off the mark, but have you tried adding a comma between $cc1 and $cc2??
Hence,
That may be why the gmail address is not allowed to follow the abc address.
Best,
Rob.
This may be way off the mark, but have you tried adding a comma between $cc1 and $cc2??
Hence,
PHP Syntax (Toggle Plain Text)
$headers = "From: " . $from . "\r\n" . "Cc: " . $cc1 . ", " . $cc2;
That may be why the gmail address is not allowed to follow the abc address.
Best,
Rob.
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
•
•
•
•
Hi,
This may be way off the mark, but have you tried adding a comma between $cc1 and $cc2??
Hence,
PHP Syntax (Toggle Plain Text)
$headers = "From: " . $from . "\r\n" . "Cc: " . $cc1 . ", " . $cc2;
That may be why the gmail address is not allowed to follow the abc address.
Best,
Rob.
•
•
Join Date: Jan 2008
Posts: 141
Reputation:
Solved Threads: 19
No problem, and one last thing to tidy the line of code up...
You don't need to concatenate if the variables are enclosed within double quotes, although being a postaholic, I expect you know this
A matter of personal preference I suppose.
R.
PHP Syntax (Toggle Plain Text)
$headers = "From: $from\r\nCc: $cc1, $cc2";
You don't need to concatenate if the variables are enclosed within double quotes, although being a postaholic, I expect you know this

A matter of personal preference I suppose.
R.
![]() |
Similar Threads
- PHP Mail Error (PHP)
- PHP mail() (Sendmail) Problem :( (PHP)
- Email piping to script problem (PHP)
- Problems with PHP mail function. (PHP)
- PHP -I just don't know.. (PHP)
- PHP email problem (PHP)
Other Threads in the PHP Forum
- Previous Thread: backup from MySQL database
- Next Thread: Running PHP files without .php extension
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






