Hello,
I was wondering why my mail (dont by PHP) is not being understood in thunderbird (of gmail) when the source looks very similar to one that does (I sent one to myself from gmail).
I'll quote 3 files: dobackup.php (the file that sends the mail), myemail.txt (the source of the email that PHP sent) and googleemail.txt (the exact same email that gmail sent).
Everything else that dobackup.php is told to do works fine.
dobackup.php (details removed for security):
<?php
$date1 = date("d-m-y") . "~";
$date2 = date("H") + 6;
$date3 = ":" . date("i");
$date = $date1 . $date2 . $date3;
echo $date . "<br>";
exec("cd /home/rowanpar/public_html/lfc/backup/db");
exec("mysqldump --opt -p****** -u******* rowanpar_lfc | gzip >db/$date.gz");
exec("cd ../");
exec("echo $date >> log.txt");
if ($_SERVER['HTTP_USER_AGENT'] != "") {
echo '<a href="db/' . $date . '.gz">Download Back Up File</a> (Right Click > Save As)';
}
exec("wget -q http://zf9.co.uk/lfcbackup/getbackup.php?date=$date");
if (file_exists("getbackup.php?date=$date")) {
$f = fopen("getbackup.php?date=$date", "r");
$well = fread($f, filesize("getbackup.php?date=$date"));
fclose($f);
if (eregi("COMPLETE", $well)) {
exec("echo Uploaded at $date >> ulog.txt");
if ($_SERVER['HTTP_USER_AGENT'] != "") {
echo '<br>Status of Upload to Backup Server: ';
echo '<a href="http://zf9.co.uk/lfcbackup/db/' . $date . '.gz">COMPLETE</a>';
}
} else {
exec("echo Failed at $date >> ulog.txt");
if ($_SERVER['HTTP_USER_AGENT'] != "") {
echo '<br>Status of Upload to Backup Server: FAILED';
echo '<br>With Error:<br>';
require("getbackup.php?date=$date");
}
}
exec("rm getbackup.php?date=$date");
$mime_boundary = "==Multipart_Boundary_x".md5(mt_rand())."x";
$f = fopen("db/$date.gz", "rb");
$data = fread($f, filesize("db/$date.gz"));
fclose($f);
$data = chunk_split(base64_encode($data));
$headers = "From: LFC Backup <backup.lfc@gmail.com>
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary: \"{$mime_boundary}\"";
$message = "
--{$mime_boundary}
Content-Type: multipart/alternative;
boundary: \"{$mime_boundary}\"
--{$mime_boundary}
Content-Type: text/plain; charset=\"iso-8859-1\"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Backed Up at $date
--{$mime_boundary}
Content-Type: text/html; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Backed Up at $date<br>
--{$mime_boundary}
--{$mime_boundary}
Content-Type: application/x-gzip;
name: \"$date.gz\"
Content-Disposition: attachment;
filename: \"$date.gz\"
Content-Transfer-Encoding: base64
$data
--{$mime_boundary}--";
if (@mail("rowanparker.uk@gmail.com", "LFC Backup", $message, $headers)) {
exec("echo Email Sent at $date >> mlog.txt");
if ($_SERVER['HTTP_USER_AGENT'] != "") {
echo '<br>Backup Email: Sent';
}
} else {
exec("echo Email Not Sent at $date >> mlog.txt");
if ($_SERVER['HTTP_USER_AGENT'] != "") {
echo '<br>Backup Email: Not Sent';
}
}
}
?>
myemail.txt:
From - Wed Jan 3 21:00:44 2007
X-Account-Key: account2
X-UIDL: GmailId10fe9c35eae6a418
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Delivered-To: rowanparker.uk@gmail.com
Received: by 10.82.145.16 with SMTP id s16cs1194106bud;
Wed, 3 Jan 2007 13:00:32 -0800 (PST)
Received: by 10.67.91.6 with SMTP id t6mr12221802ugl.1167858032189;
Wed, 03 Jan 2007 13:00:32 -0800 (PST)
Return-Path: <rowanpar@serv01.siteground131.com>
Received: from serv01.siteground131.com (ns1.siteground131.com [67.15.250.4])
by mx.google.com with ESMTP id k30si8018121ugc.2007.01.03.13.00.29;
Wed, 03 Jan 2007 13:00:32 -0800 (PST)
Received-SPF: pass (google.com: domain of rowanpar@serv01.siteground131.com designates 67.15.250.4 as permitted sender)
Received: from rowanpar by serv01.siteground131.com with local (Exim 4.63)
(envelope-from <rowanpar@serv01.siteground131.com>)
id 1H2DDm-0001oI-Po
for rowanparker.uk@gmail.com; Wed, 03 Jan 2007 15:00:27 -0600
To: rowanparker.uk@gmail.com
Subject: LFC Backup
From: LFC Backup <backup.lfc@gmail.com>
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary: "==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x"
Message-Id: <E1H2DDm-0001oI-Po@serv01.siteground131.com>
Date: Wed, 03 Jan 2007 15:00:26 -0600
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - serv01.siteground131.com
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [32469 972] / [47 12]
X-AntiAbuse: Sender Address Domain - serv01.siteground131.com
X-Source:
X-Source-Args:
X-Source-Dir:
--==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x
Content-Type: multipart/alternative;
boundary: "==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x"
--==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x
Content-Type: text/plain; charset="iso-8859-1"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Backed Up at 03-01-07~21:00
--==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Backed Up at 03-01-07~21:00<br>
--==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x
--==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x
Content-Type: application/x-gzip;
name: "03-01-07~21:00.gz"
Content-Disposition: attachment;
filename: "03-01-07~21:00.gz"
Content-Transfer-Encoding: base64
H4sIAGcZnEUAA7xcbXPbOJL+fPkVmP1wcrZoLd9fMjW1I9tK4h2/raTs3NylSqEl2OKEInUkZY/n
6v77dYMASEmQIDqpm7EUGUA/aDSebjQAyqen5Ppl/M8rMl8vV8Qy+9Gb01P4IR/zsnpH0nwWpwv4
[Miss a huge chunk]
7/bx6ebuA/wjN1678tL9n28f2O0P1wTYpSsSznd37x4/nO+fbs7397c3+NEEXLlyuD9vu3I83z5s
w8qvgvzpP4Ufh/MWKRMA
--==Multipart_Boundary_x0ee2f775ad911e8535d63a59f2a252d5x--
googleemail.txt:
From - Wed Jan 3 20:32:01 2007
X-Account-Key: account2
X-UIDL: GmailId10fe9a8d77f1c10e
X-Mozilla-Status: 0001
X-Mozilla-Status2: 10000000
Delivered-To: rowanparker.uk@gmail.com
Received: by 10.82.145.16 with SMTP id s16cs1192444bud;
Wed, 3 Jan 2007 12:31:35 -0800 (PST)
Received: by 10.35.82.16 with SMTP id j16mr40199097pyl.1167856293573;
Wed, 03 Jan 2007 12:31:33 -0800 (PST)
Received: by 10.35.94.6 with HTTP; Wed, 3 Jan 2007 12:31:33 -0800 (PST)
Message-ID: <5026e5ae0701031231l1e1d75a9m1e4da345e5964e9a@mail.gmail.com>
Date: Wed, 3 Jan 2007 20:31:33 +0000
From: "LFC Backup" <backup.lfc@gmail.com>
To: "Rowan Parker" <rowanparker.uk@gmail.com>
Subject: LFC Backup
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_71626_19508774.1167856293392"
------=Part_71626_19508774.1167856293392
Content-Type: multipart/alternative;
boundary="----=Part_71627_23615738.1167856293392"
------=_Part_71627_23615738.1167856293392
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Backed Up at 03-01-07~20:28
------=_Part_71627_23615738.1167856293392
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Backed Up at 03-01-07~20:28<br>
------=_Part_71627_23615738.1167856293392--
------=_Part_71626_19508774.1167856293392
Content-Type: application/x-gzip; name="03-01-07~20:28.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="03-01-07~20:28.gz"
X-Attachment-Id: f_ewi7g8lo
H4sIAAkSnEUAA7xcbXPbOJL+fPkVmP1wcrZoLd9fMjW1I9tK4h2/raTs3NylSqEl2OKEInUkZY/n
6v77dYMASEmQIDqpm7EUGUA/aDSebjQAyqen5Ppl/M8rMl8vV8Qy+9Gb01P4IR/zsnpH0nwWpwv4
[Miss out a huge chunk]
8/YP593hDvHhE68duXX+5/2Jwn66pkAPXdFwPBxeP9wd78+74/39focfVcGVI5vz4/Ir5fP+tBzL
v7Lks1/77/ryVh0TAA==
------=_Part_71626_19508774.1167856293392--
Thank you very much, Rowan.