Sending mail with php mailer
Hi Team,
I have created back up script which creates log file.I need to send mail with the content of log as body message .Below are the details log file will generated in /mnt/with today's date as file name log=/mnt/`date +%F`.log #vi mail.php <head> <title>PHPMailer</title> </head> <body> <?php require("class.phpmailer.php"); $To = 'xyz@gmail.com'; $From = 'xyz@gmail.com'; $FromName = 'xyz'; $Subject = 'Weekly backup status'; $today = date('Y-m-d'); $Message = ; $HTML = true; $Mail = new PHPMailer(); $Mail->IsSMTP(); // send via SMTP $Mail->Host = "Smtp.gmail.com"; $Mail->SMTPAuth = true; // enable SMTP authentication $Mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent $Mail->Hostname = "Smtp.gmail.com"; // sets the SMTP server $Mail->Port = 465; // set the SMTP port for the GMAIL server $Mail->Username = "xyz@gmail.com "; // SMTP account username $Mail->SMTPSecure = "ssl"; // SMTP account username $Mail->Password = 'xyz1234'; // SMTP account password //$Mail->Host = $Host; //SMTP server $Mail->SMTPAuth=true; $Mail->From = $From; $Mail->FromName = $FromName; $Mail->AddAddress($To); $Mail->AddReplyTo($From); $Mail->WordWrap = 50; // set word wrap $Mail->IsHTML($HTML); $Mail->Subject = $Subject; $Mail->Body = $Message; echo "<pre>"; print_r($Mail); if($Mail->Send()) { echo "Message Sent"; } else { echo "Message Not Sent<br/>"; echo "Mailer Error: " . $Mail->ErrorInfo; } ?> </body> </html> ############################# File ends here ################ What should be the parameter for $message in the above file to send the content of log file i.e. /mnt/`date +%F`.log in a mail . Any help is appreciable. Thanks in advance |
Hi there,
Try this PHP code: Code:
$Logfile = '/mnt/' . date("Y-m-d") . '.log'; Clifford |
Quote:
|
Quote:
I had to modify the script as per request .Now my log file is located as below . TAR=/bin/tar DIR=`date +%m%d%Y` DES=/vol-112124 MYDIR=$DES/$DIR LOG=$MYDIR/`date +%F`.log Can you tell , what should be the path of $message I tried below way, but not working. $Logfile = '$MYDIR' . date("Y-m-d") . '.log'; |
Hi there,
I assume your commands above to set the variables are in a shell script. Are you calling the PHP code from the same script after setting these? If so, you need to add this to the script after setting LOG: Code:
export LOG Code:
$LogFile = getenv('LOG'); Code:
$DIR = date("mdY"); |
Quote:
|
Quote:
Hi cliffordw, Can I send mail to multiple email addresses ?If so , can you tell me the chanages need to make in mail.php . |
All times are GMT -5. The time now is 06:50 PM. |