How to send email using PHP code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Vadamalar
Forum Newbie
Posts: 1
Joined: Mon Mar 20, 2006 5:49 am

How to send email using PHP code

Post by Vadamalar »

Code: Select all

<?php

mail("To:$Todomainname@.com","$Subject","$some message body","From:$Fromdomainname.com");
?>

If i try to execute this, i am getting error reporting like "SMTP server response: 550 5.7.1 Unable to relay for Todomainname.com".

Please help it out.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

"To:$Todomainname@.com"

That is your problem. whats this To: doing there? This section is supposed to be just a e-mail address, the address that you want to send the e-mail to. it should be like

Code: Select all

mail("someone@hotmail.com","$Subject","$some message body","From:$Fromdomainname.com");
or somthing like that.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

can I recommend PHPmailer? You will likely have a lot of problems sending to hotmail and other email providers becasue of misused headers. PHPmailer is very effective and 99.9% gets the job done ;)
Post Reply