php email attachment and message

Solutions on MaxInterview for php email attachment and message by the best coders in the world

showing results for - "php email attachment and message"
Lara
28 Feb 2018
1    $filename = 'myfile';
2    $path = 'your path goes here';
3    $file = $path . "/" . $filename;
4
5    $mailto = 'mail@mail.com';
6    $subject = 'Subject';
7    $message = 'My message';
8
9    $content = file_get_contents($file);
10    $content = chunk_split(base64_encode($content));
11
12    // a random hash will be necessary to send mixed content
13    $separator = md5(time());
14
15    // carriage return type (RFC)
16    $eol = "\r\n";
17
18    // main header (multipart mandatory)
19    $headers = "From: name <test@test.com>" . $eol;
20    $headers .= "MIME-Version: 1.0" . $eol;
21    $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
22    $headers .= "Content-Transfer-Encoding: 7bit" . $eol;
23    $headers .= "This is a MIME encoded message." . $eol;
24
25    // message
26    $body = "--" . $separator . $eol;
27    $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
28    $body .= "Content-Transfer-Encoding: 8bit" . $eol;
29    $body .= $message . $eol;
30
31    // attachment
32    $body .= "--" . $separator . $eol;
33    $body .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;
34    $body .= "Content-Transfer-Encoding: base64" . $eol;
35    $body .= "Content-Disposition: attachment" . $eol;
36    $body .= $content . $eol;
37    $body .= "--" . $separator . "--";
38
39    //SEND Mail
40    if (mail($mailto, $subject, $body, $headers)) {
41        echo "mail send ... OK"; // or use booleans here
42    } else {
43        echo "mail send ... ERROR!";
44        print_r( error_get_last() );
45    }
46
Ayden
27 Apr 2016
1$my_file = "somefile.zip";
2$my_path = "/your_path/to_the_attachment/";
3$my_name = "Olaf Lederer";
4$my_mail = "my@mail.com";
5$my_replyto = "my_reply_to@mail.net";
6$my_subject = "This is a mail with attachment.";
7$my_message = "Hallo,rndo you like this script? I hope it will help.rnrngr. Olaf";
8mail_attachment($my_file, $my_path, "recipient@mail.org", $my_mail, $my_name, $my_replyto, $my_subject, $my_message);
Sophie
23 Jul 2020
1<?php
2function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
3 $file = $path.$filename;
4 $file_size = filesize($file);
5 $handle = fopen($file, "r");
6 $content = fread($handle, $file_size);
7 fclose($handle);
8 $content = chunk_split(base64_encode($content));
9 $uid = md5(uniqid(time()));
10 $header = "From: ".$from_name." <".$from_mail.">\r\n";
11 $header .= "Reply-To: ".$replyto."\r\n";
12 $header .= "MIME-Version: 1.0\r\n";
13 $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
14 $header .= "This is a multi-part message in MIME format.\r\n";
15 $header .= "--".$uid."\r\n";
16 $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
17 $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
18 $header .= $message."\r\n\r\n";
19 $header .= "--".$uid."\r\n";
20 $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
21 $header .= "Content-Transfer-Encoding: base64\r\n";
22 $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
23 $header .= $content."\r\n\r\n";
24 $header .= "--".$uid."--";
25 if (mail($mailto, $subject, "", $header)) {
26 echo "mail send ... OK"; // or use booleans here
27 } else {
28 echo "mail send ... ERROR!";
29 }
30}
queries leading to this page
php mail 28 29 example with attachmentssend attachment php mail formphp script to send mail with attachment codehow to send attachment in email using php mailerhow to send video throught mail in phpsend email with attachment sendgrid phpphp email attachmentsend attachment with mail 28 29 phpsend email in phpaccess email attachments on server phpsend mail with view laravelhtml form send emailphpmailer add attachmentfile attachment in php mail functionsending attachments in mail phpattachemnt php php get email from serverhow to send an email using phpmail message body phplaravel mail send attachmentphp form send email with attachmentsending attachments phpsend email using phpphp save attachment from emailphp send email smtpsend emails with attachement in phpsend email with attachment using phpphp html email template with attachmentphp mail function with html and attachment examplehow to send email attachment doc file using phpphp contact form send emailphp script to send mail with attachmentsend a file using mail 28 29 phpmail query with attachment in phpsend attachments over email using phpsendgridemail attachment example phpphp mail attachmentssend email with attached file phpattachment in mail in phpphp mail function attachmentsend mail with attachment using phpphp email attachment and messagemail 3esend with attachment in php demomail attachment n phphow to send attachment file in mail phpphp mailer script with attachmentphp send email with attachment from formphp mail upload attachmenthow to send attachment mail through server in phpphp form with attachment to emailhow to send attachment in mail phphow to send attachment in mail in phpphp mail attach filephp mail with attachmentmail in php with attachmentsend attachment in mail php 7 2bhtml render in mail with attachment php mailhow to add attachment ni php to emailhow to send mail in phpsending email with attachment in phpsending an email with a file with phpphp email send html viewphp how to send file to emailemail header add attachment phpphp send and receive emailhow to send email with attachment php emailsend file email phpsend javascript in nodemailerphp sendmail with attachmentphp 7 send email with attachmentquick php script to send email to usersend email with attachment in php examplephp mail function with attachmentphp send mailphpmailer with attachment examplephp send mail with pdf attachment examplesend attachments in phpmailerhow to add attachment to email from htmlsmtp mail with attachment in php examplesend email attachment phpphp email attach filephp add mail attachmentphp email send with attachmentphp to send email with attachmentsend email with attachment in php using mailphp email attach 28 29ad atatchmen mail phpattachment in phpmailerphp mail attechmentphp mail attach file from serverphp add attachment to emailsending html form data to an email address without phpsend email php smtp gmailphp form email sendhow to send file attachment in phpphp send email attachmentsend mail including from phpmail php send attachmentsending file attachment php mailsend email with attachment image in phpsend email as attachment phpattachment in php mail functionphp mailer send emailphp mail 28 29 attachmentsend attachment smtp phpphp sendmail upload attachmenthow to send attachment in mail using phpsend email in php javatpointsend attachment using smtp in phpphpsendmail with attachmentphp change sender fo mail 29 28 fundtionphp send email attachmentshow to send email with phpmailer with attachmenthwo to send attachment in php email by mail methodphp email message and attachmentmailjet php add attachmentsend attachment in mail 2bphpmail with attachment in phpphp script to send email with attachment from formfile attached to an email message are sent as in phpemail attachment php 24 filehow to send an email with phpmail attachment function php phpmailphp file attechment emailphp mailer send attachmentphp mailer add attachment from a urlphp email with attachmentsend a attachment through phpfunction to send email in phpsend files to email phpphp mail body messagephp mail function send attachmentphp mail send with filesend email with file attachment phpshare document email phpsend file attachments in email phpphp send file to emailmail attachment in phpsend attachment in mail using phpphp send attached file emailsend attachment php mailphp send to emailread email attachment phpsend mail with attachement phpsend php mail with attachmenthow to send attachment in phpmailermail file in phphow to send email through pythonattach something to an email php javascriptmail with attachment php codehow to add attachment in phpmailerphp send mail with attachment examplehow to get attachments to emails phpphp send email smtp with attachmentsend fil to mail with phpmail function in php with attachmentusing mail function in php send attachmentphp send mail with excel attachmentphp create pdf and attach to emailphp send mail attachmentphp send email gmail send html email in phpfile attachment email in phpsend attachment in mail phpadd attachment in phpmailerphp mailer send attachmentsphp mail file attachment showing content in mailsend mail attachment with phpphp form to send email how to sent attachmentsend attachment in mail php mailerphp send attachment emalphp mail function with attachment examplesend attachment with php mail functionsend email with attachment in php wordpressemail attachment phpsend mail with attachment in phpmailerphp mail add attachmentphprad send mailhow to send email with attachment using phpphpmailer send attachmentadd attachment phpmailerphp mail attachment scriptphp mail 28 29 with attachmentmail send attachment phpphp sending an emailattach a file to email phpsend form attachment in mail using phpphp send mail with attachmentsattachment in email phpsend attachment phphow to send attachement with mail 28 29 phphow to put attachment in body of email phpattachments in php sending mailsend format email with attachment php examplephp mail attachment form optionphp mailer attachmentsend email with attachment in php using phpmailer 5dsend email with attachment phpphp send email from serverphp send emailsphp mail attachmentphp send data to emailsend content php file to emailsend mail from contact form phphow to send attachment file in mail in phpphpmailer send mail with attachmentphp send database as file attachment in emailphp code for email with attachmentphp send email examplephp send email attachment email 3esend 28 29 3bsend attachment in mail phpmailerphp send file via mailphp send attachment to email after submissionsend attachment using php mailerphp send email with attachment html filephpmailer email attachmenthow to send attachment phpattachment in phpmailer examplesend mail attachment using mail phpphp send mail with attachmentsend attachments and html with php mailinsert file as email body phpphpmailer send attachment from contentsend mail with attachment in phpsend mail with attachment using smtp in phpphp mail send attachment filesend email with attachment using php mailerphp send emailphp send form information as attachment via emailmail php not sending attachmentsphp get email attachmentphp send email with attachment exampleoutlook php send mail with attachmentsattachment with phpmailerphp mailer attachmentshow to send email with attached file in phpemail example file phpphp send email with attachmentmail attachment in php with link php send attachment with emailhow to send email from a website using phpphpmailer send email class with attachmentphp mail with attachment and htmladding an upload attachment to mail phpphpmailer with attachmentphp send mail yahoophp send email with image attachmentphp send email with attached filephp sending email with attachmentsend attachment in mail php with html formatsend attachment in phpmailerhow to send attachment in email in phphow to send file with mail in php 24mail addattachment phpform to email with 2 attachment phpsend attachment php mail form phpsend email php attached filephp send email with file attachmentphp mail file attachmentphpmailer send with attachmentsmtp mail with attachment in phpcan you send a email via php without having email pluginphp add mail string attachmentphp auto send email attachmentmail php attachmentphp code to send email with attachmentemail with attachment php php send emails from an outlook accounthow to send attachment in mail using phpmailersmtp mail function in php for file uploadsend attachments over email using phpmailersend attachment file and body text with email in phpsend email with attachment in phpsend mail php with attachmentphp attachment mailphp mail function add attachmentc 23 code to send email using smtpadd attachment in mail using phpadd file to mail phpsend attachment in php mailmail attachment function php phpmailersend email and attache file in phpphp mail attachment optionssend mail using phpsending email with attachment php examplephp mail 28 29 with attachment file php email says there is an attachmentphp send html email as attachmentphp send email text filesend email with attachment in php using phpmailerhow to send attached file email in phphow to use php mailer with attachmentphp mail attachment syntaxsent email with attachment in phpattachment php mailphp attachmentsend a file mail phpadd attachment in phpphp email add attachmentphp attach file to emailphpmailer send email with attachmentphpmailer send attachment from formphp send mail attach filemail attachment phpadding attachments from html to phpmailmail function with attachment in phpphp send email with attachment phpmailersend attachment using phpmailerhow to send email using sendgrid from phpphp add file to emailhow to add attachments in php mailerfuntion to add attachment to mail in phpunable to send email using php mail 28 29php sending emailphp mail send attachmentphp code to send attachment in emailphp email attachment scripthow to send mail with attachment in phpchange attachment in sent email in phpmail function display html and attachment in content in phpphp send message to emailsend mail phpsend email with attachment phpmailerphp send file emailphp mail sendphpmailer send image attachmentphp email attachment and message