I have setup dkim on my server using opendkim(centos). when php executes mail command(on website eg forgot.php). it sends an email signed with DKIM. but i also setup a cron job to run mailcron.php which sends out emails.
i setup cron by typing crontab -e [ENTER] */5 * * * * php -q /var/www/html/mailcron.php [save]
OUTPUT from cron log
Jul 21 03:15:01 veepiz crond[3819]: (root) CMD (/etc/webmin/status/monitor.pl) Jul 21 03:15:01 veepiz crond[3820]: (root) CMD (/etc/webmin/virtual-server/collectinfo.pl) Jul 21 03:15:01 veepiz crond[3821]: (root) CMD (php -q /var/www/html/mailcron.php) why are emails sent using cron not signing while those running directly from the site signing.
<?php set_time_limit(0); error_reporting(E_ALL); $dbserver='localhost'; $dbuser='cccc'; $dbpassword='xxxx'; $dbname='veepiz'; $homepath="http://www.veepiz.com"; $supportemail="[email protected]"; $localpath = ''; $domainpath = '.veepiz.com'; $dblink=mysql_connect($dbserver,$dbuser,$dbpassword); require("class.phpmailer.php"); if (!$dblink) { die('Could not connect to database.<br/>'.mysql_error()); } if (!(mysql_select_db($dbname,$dblink))) { die('Could not select database<br/>'.mysql_error()); } $q="SELECT * FROM emailcron ORDER BY id ASC"; $r=mysql_query($q); if ($r) { if (mysql_num_rows($r)>0) { $message=""; $n=0; $c=0; while ($o=mysql_fetch_object($r)) { $x = new PHPMailer(); $x->From = "[email protected]"; $x->FromName = "Veepiz"; $x->AddAddress($o->emailaddress,$o->toname); $x->AddReplyTo("[email protected]", "Veepiz"); $x->WordWrap = 50; // set word wrap to 50 characters $x->IsHTML(true); // set email format to HTML $x->Subject = $o->subject; $x->Body = nl2br($o->content); $x->AltBody = strip_tags($o->content); if(!$x->Send()) { $c++; $message .= "Message could not be sent. <br/>\n"; $message .= "Mailer Error: " . $x->ErrorInfo."<br/>\n"; } else { $n++; mysql_query("DELETE FROM emailcron WHERE id=".$o->id); } } if (strlen($message)>0) { echo $message; } else { echo "Mails sent:$n; Mails Failed:$c"; } } } ?>