+ Reply to Thread
Results 1 to 3 of 3

Thread: Help with mail in script
      
   

  1. #1
    adonairc's Avatar
    adonairc is offline Sergeant
    Join Date
    Oct 2005
    Posts
    36

    Question Help with mail in script

    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.

    PHP Code:
    <?
    $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>';
    }
    load_template(tpl_path.'password_sent.tpl');
    ?>
    If any body can help me I'll be very thankful.

    Ado

  2. #2
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: Help with mail in script

    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

    <?php
    require("class.phpmailer.php");

    $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->AddAddress($email_to);
    $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

  3. #3
    adonairc's Avatar
    adonairc is offline Sergeant
    Join Date
    Oct 2005
    Posts
    36

    Thumbs up Re: Help with mail in script

    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.

    Ado

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49