View Full Version : Help with mail in script

02-19-2006, 09:16 PM
Hi, i'm writing this because i'm thinking in cut my veins with a lettuce leaf, I have passed weeks and weeks trying to change the way scripts send php mail in order to be sent trough authenticated smtp and i don't find the way.

I've tried php mailer, smtp.class, and a lot of scripts found in google and nothing; I don't know if anyone here can help me.

The next is a code of a script, when a user register itself, it's suposed to receive a confirmation mail... but of course, nothing happens because uses the php mail function.

$result = mysql_query("SELECT * FROM $membtable WHERE m_user='$en[user]' OR m_email='$en[email]' LIMIT 1") or die(mysql_error());
$line = mysql_fetch_assoc($result);
if (mysql_num_rows($result) == 0) {
$en['send_result'] = _sent_code_fail;
} else {

$temp = '';
for ($k = 1;$k<=7;$k++)
$temp .= chr(97+rand(0,25));
$en = array_merge($line,$en);
$en['pass'] = $temp;
$mail = emailtemplate('emails/send_password.tpl');

mail($line[m_email], $mail[subj], $mail[body],
"From: ".admin_email."\r\n"
."Reply-To: ".admin_email."\r\n"
."X-Mailer: PHP/" . phpversion());
mysql_query("UPDATE $membtable SET m_pass='".md5($temp)."' WHERE m_id=$line[m_id]") or die(mysql_error());
$en['send_result'] = _pass_sent.' <b>'.$line[m_email].'</b>';

If any body can help me I'll be very thankful.


02-20-2006, 03:45 AM
I use phpmailer, it works fine, perhap you weren't using it correctly, here some code that should work, just change it to fit your needs


$email_from = "admin@mysite.com";
$email_subject = "Hello";
$email_message = "Email Message";
$email_to = $_POST['email'];

$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "localhost"; // SMTP server
$mail->From = $email_from;
$mail->FromName = "SITENAME";
$mail->Sender = $email_from;
$mail->Subject = $email_subject;
$mail->Body = $email_message;
$mail->WordWrap = 50;

Try testing that,
change the $email_to, make it
$email_to = "you@yoursite.com";
and change the $email_from, $email_subject, & $email_message to whatever you want.

Hope this helps

02-20-2006, 11:09 PM
Thanks budy, that worked, I was using a SMTP plugin with phpmailer maybe that was the problem, now is just sending blank mails, but at least sends something ja ja ja, I think is only thing to find the correct variable.

Thanks one more time.