1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with php mailing bot

Discussion in 'General Programming Chat' started by ruicosta, Jan 11, 2013.

  1. ruicosta

    ruicosta Regular Member

    Joined:
    Nov 23, 2009
    Messages:
    209
    Likes Received:
    21
    Location:
    Croatia
    Hey guys!

    I've recently linked my pop mail with gmail account and I'm not happy with the frequency of fetching mails from pop server. As I've read - gmail calculates how often you receive mail and decides how frequent to check. Rule of a thumb is that if you receive your mail every 10 mins - it will check every 5 minutes.

    I would like to make a mailing bot which would send email to my pop account every 15 mins, so that gmail would check it every 7 mins and then I could filter those messages in gmail out and delete them.

    This is the php script uploaded to my server

    Code:
    <?php    $to      = 'mymail@mypopmail.com';
        $subject = 'Gmail Reminder';
        $message = 'Just a reminder to Gmail to fetch my gmail';
        $headers = 'From: bot@mydomain.com' . "\r\n" .
                    'X-Mailer: PHP/' . phpversion();
        mail($to, $subject, $message, $headers);
    ?>
    

    and this is a cron job that I've entered in my cpanel:

    Code:
    */15  *  *  *  *  php http://www.mydomain.com/mail.php > /dev/null 2>&1
    Hosting support says that cron runs normally but I am not getting any emails from it. Only way I can get it to send an email is by visiting mail.php link in my browser.

    Any help would be appreciated
     
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    Wrong. You need the absolute path on the file system of the file, not the web address as an argument to php & I 'd also use an absolute path for the php executable as well.
     
    • Thanks Thanks x 1
  3. Paranoid Android

    Paranoid Android Jr. VIP Jr. VIP Premium Member

    Joined:
    Jun 20, 2010
    Messages:
    1,460
    Likes Received:
    2,223
    Gender:
    Male
    Occupation:
    Pantie Thief
    Location:
    Native America
    use webphp if you want to use the url and not the fs path
     
  4. ruicosta

    ruicosta Regular Member

    Joined:
    Nov 23, 2009
    Messages:
    209
    Likes Received:
    21
    Location:
    Croatia
    Thanks a lot for your help!

    Which one is correct?

    Code:
    php /public_html/MYDOMAIN.COM/mail.php > /dev/null 2>&1
    or

    Code:
    php usr/local/public_html/MYDOMAIN.COM/mail.php > /dev/null 2>&1
     
  5. Paranoid Android

    Paranoid Android Jr. VIP Jr. VIP Premium Member

    Joined:
    Jun 20, 2010
    Messages:
    1,460
    Likes Received:
    2,223
    Gender:
    Male
    Occupation:
    Pantie Thief
    Location:
    Native America
    yo, dont confuse the guy, cpanel paths are somethng like /home/cpuser/public_html/file.php
     
    • Thanks Thanks x 1
  6. ruicosta

    ruicosta Regular Member

    Joined:
    Nov 23, 2009
    Messages:
    209
    Likes Received:
    21
    Location:
    Croatia
    I think I got it right now, thanks :)