Email issues

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
demosthenes
Forum Newbie
Posts: 2
Joined: Thu Oct 26, 2006 8:27 am

Email issues

Post by demosthenes »

I am using the following code to send an email. It will send it to my office email address which is using an exchange server, but it won't send it to web based email addresses such as yahoo or google. Can someone tell me whats wrong?

$email = "myemail@yahoo.com";

$subject = "My Subject Goes Here";

$message = "Here is my message";

mail($email, $subject, $message, "From: $email");



Thanks,

Demosthenes
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post by akimm »

wrap your code in

Code: Select all

 bracers [/ php]

here is a code that will work, however, this type of function is not suggested, because, its not safe.  Once you have a better grasp of PHP I think using solid mailing programs like swiftmailer should be in order. Your choice, but this code is not a solid one, this method isn't.

[syntax=php]#msg =
#msn .=
#the above is a way to add to pre existing variable, concactenation
$msg = "#given subject\r\n"; 
$msg .= "Sender's NAME: \t{$_POST['name']}\r\n"; 
$msg .= "Sender's EMAIL:\t{$_POST['sender_email']}\r\n"; 
$msg .= "Sender's TITLE:\t{$_POST['title']}\r\n"; 
$to = "#email\r\n"; 
$subject = "##your subject\r\n"; 
$mailtoheaders = "#from who <##email>\r\n";
#if you have a $_POST['sender_mail'] you can reply to them in your mail 
$mailheaders .= "Reply-To: {$_POST['sender_email']}\r\n"; 
mail($to, $subject, $msg, $mailheaders);[/syntax]
Post Reply