Problem sending emails using cron job

I basically have a regular php mail script function that should run so often with a cron job, however some emails don't work when they really work if I run the script manually.

for example, in my hoshing cron control panel, I enter domain.ca/pear/Mail/test_mail.php

I do not enter the URL correctly? Should I use some kind of cron job command

require_once('Mail.php');
require_once('../Mail_Mime/mime.php');


 $mail = Mail::factory("mail");

    $headers = array("From"=>"me@example.com", "Subject"=>"Test Mail");
    $body = "This is a test!";
    $mail->send("example@gmail.com", $headers, $body);

This is exactly my script email address

In addition, cron works with specific email addresses, such as gmail.

So emails like my schools don't work in cron, but work when they are done manually. In addition, the script updates the database using cron ..

I have this in my .sh file:

/usr/local/nf/php5/bin/php -f ./test_mail.php
+3
1

URL cron. , lynx wget cron:

* * * * * wget http://mypage.com

, wget lynx, , . /tmp /dev/null, . :

man wget wget --help .

, Artefact2 : * * * * * PHP .php. , shebang PHP PHP- tho:

#!/usr/bin/php
<?php
// your PHP code here

Shebang PHP .

+2

Source: https://habr.com/ru/post/1795314/


All Articles