Page 1 of 1

Not able to send mails with script

Posted: Thu Jul 24, 2008 1:24 pm
by amitkpt
Hi All,

I am new to PHP. While create a web site in PHP, I have a strange problem. I am using pear php to send mails with smtp authentication. I also created small user authentication with mysql. I have a script to send mails. Problem is I am getting errors while sending mail from all users accept one. I mean it can only send mails with user (amit i.e me). I don't know where is the problem is it in the srcipt or in configuration. Because if the problem is in configuration then why it is allowing one user to send mails? I am coping the script below.

<?php
session_start();
include("templates.php");
do_html_header("Spicy Voting! Create New Poll.");
datab();
?><div id="content"><?

check_valid_user();

require_once "Mail.php";

$email = $_POST['email'];
$id = $_POST['id'];
$user = $_SESSION['vname'];
@extract($_GET);

if($email)
{

$recipients = $email;
$headers["From"] = $user;
$headers["To"] = $email;
$headers["Subject"] = "I created a new poll. Please cast your vote.";
$mailmsg = "Hi,

I just created new poll in spicyvoting.com. Please try and cast your vote and see interesting results. Also you can post your own new polls there. This is very interesting to know about thinking of different people and polling is best why to know this. Here we can make our own new polls and send that to people to know what they think? I found that very interesting. Please try that.

Please follow this link to cast your vote in my poll.

http:spicyvoting.com/polls_id.php?id=".$id."

To know more about spicyvoting visit. http://www.spicyvoting.com or Email: spicy@spicyvoting.com";

/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "mail.spicyvoting.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "spicy@spicyvoting.com";
$smtpinfo["password"] = "**********";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail = $mail_object->send($recipients, $headers, $mailmsg);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p> <a href='javascript: history.go(-1)'>Back[/url]");
} else {
echo("<div align='center'><p>Your invitation is sent to ".$email."</p></div>");
}

}
else
{
?>
<form action="<? $_SERVER['PHP_SELF']; ?>" method='post'>
Email ID of your friend: <input type="text" name="email"> <p>
<input type="submit" value="Invite">
</form>
<?
}



?></div><?
do_html_footer();
?>

I am getting following error while not sending the mail:

Failed to add recipient: polls@spicyvoting.com [SMTP: Invalid response code received from server (code: 550, response: Verification failed for Unrouteable address Sender verify failed)]


Please reply as soon as possible.

Thanx in Advance