如何将图像发送到电子邮件

时间:2013-12-19 06:28:40

标签: javascript php email send

这里我有我的代码。我想将存储在服务器中的图像发送到电子邮件。我尝试使用此代码但不知何故它显示成功,但它没有发送到我的电子邮件

php代码     

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
   <title>Birthday Reminders for August</title>
</head>
<body>
   <p>Here are the birthdays upcoming in August!</p>
   <table>
     <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
     </tr>
     <tr>
      <td>Image</td><td>3rd</td><td><img       src="http://serverlocation/AndroidServer/Question/cp1200Week1q1.png"></td><td>1970</td>
     </tr>
     <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
     </tr>
  </table>
</body>
</html>
';

 // To send HTML mail, the Content-type header must be set
 $headers = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <thegunner_vincent@yahoo.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";


// Mail it
mail($to, $subject, $message, $headers);
?>

这里java script code用于调用php函数:

function sendEmail() {
            uploadGraph();
            db.transaction(function(tx) {
                var statement = 'SELECT email FROM temp;';
                tx.executeSql(statement, [], function(tx, results) {
                    var len4 = results.rows.length;
                    var email = results.rows.item(len4 - 1).email;
                    var filter = /\S+@\S+\.\S+/;
                    var emailperson = prompt("Please enter your e-mail", email);
                    if (emailperson !== "" && filter.test(emailperson))
                    {
                        alert(emailperson);
                        db.transaction(function(tx) {
                            var state = "UPDATE temp SET email='" + emailperson + "';";
                            tx.executeSql(state);
                        });
                        //uploadGraph();

                        var setIP = document.getElementById("setIP").value;
                        var str = document.getElementById("lectureid").value;

                        if (setIP == "") {
                            setIP = "10.0.2.2";
                        }

                        if (window.XMLHttpRequest)
                        {// code for IE7+, Firefox, Chrome, Opera, Safari
                            xmlhttp = new XMLHttpRequest();
                        }
                        else
                        {// code for IE6, IE5
                            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        xmlhttp.onreadystatechange = function()
                        {
                            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                            {
                                alert("Email send");
                            }
                        }
                        var url_serv = "http://" + setIP +   "/AndroidServer/sendEmail.php?lectureid=" + str;
                        xmlhttp.open("GET", url_serv, true);
                        xmlhttp.send();

                    } else {
                        alert("email is invalid");
                    }
                });
            });

0 个答案:

没有答案