SendMail with SMTP

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
darkott
Forum Newbie
Posts: 1
Joined: Fri Jan 22, 2010 8:28 am

SendMail with SMTP

Post by darkott »

Hi I have problems with the sendmail component in wy web, after implementing SMTP auth this is not working and i have this message
Warning: mail() [function.mail]: SMTP server response: 550 Sender is not allowed:

<?php
ini_set('error_reporting',E_ALL);
ini_set('display_errors','On');

if(isset($_POST["submit"])){
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "contact@company.com.mk";
$Subject = Trim(stripslashes($_POST['Subject']));
$From = Trim(stripslashes($_POST['From']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
$msg = "Please enter all fields!";
$status = "err";
}
else{
// prepare email body text
$Body = "";
$Body .= "From: ";
$Body .= $From;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
$msg = "Message sent successfully.";
$status = "success";
}
else{
$msg = "Error occured while sending message. Please try later.";
$status = "err";
}
}
}
What should i do to fix this problem?
Post Reply