PHP send an email with image attachment

前端 未结 3 1935
情话喂你
情话喂你 2021-01-03 10:25

I\'m trying to create a script that will send an image uploaded from an iphone app I\'m developing to me in an email.

I\'ve been able to get the script to send me an

3条回答
  •  孤街浪徒
    2021-01-03 10:41

    While there are canned functions for this, what a fantastic exercise for a junior programmer!

    Very well written mti2935. It would do folks good to actually read and not just cut-and-paste. If you're sending email with php, you should understand these fundamental concepts.

    Probably some oversights from masking your real code:

    Line 23 should be:

    $data = fread($file,filesize($filename));
    

    That is, $fname should be $filename.

    Line 26 should be:

    $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"".$fname."\"\n" .
    

    Neither $x nor $files[$x] are defined.

    @Thomas Spade: I'd like to remind that you should always sanitize input (email address).

提交回复
热议问题