![]() You could use “12” as your boundary for example, though chances are that it will show up elsewhere in the message. This boundary string needs cannot appear anywhere else in the email or the mail client will not be able to parse the message correctly. The “Content-Type” header actually does two things: it indicates that there will be multiple parts in the body of various kinds, and it specifies what string is used to divide each part. "Content-Type: multipart/mixed boundary="YaGottaKeepEmSeparated"rn" The MIME-Version header tells the server to expect Multipurpose Internet Mail Extensions in the body, which allows you to have a more advanced email than simple text. By making it different than the “From:” header, the chances of this email being identified as spam increases (though if this were the only thing that caused an email client to raise a red flag this message is spam then it would probably get through). "Reply-To: Reply-To header is the email address to which an email reply should be sent. The From header specifies the email address the recipient will see the message as having come from. Each header in the string is separated with a CRLF ( rn) per RFC 2822, the standard that defines the format of email messages. Next, the $headers string is built with various mail headers. The array is iterated through at the end of the script and each address will be sent a copy of my email. $success = mail($addy, $subject, $body, $headers) Ĭertain aspects of more typical email scripts had been simplified to make the general concept easier to grasp, though I will touch on those in this breakdown.įirst, the $emailList array is populated with some email addresses I’d like to share my message with. "Content-Type: application/zip name="novyrus.zip"rn". Please install contact information attachment And we need you give us money to give some you. "You have cheap text email you have no money. "Content-Type: text/plain charset="iso-8859-1"rn". "Content-Type: multipart/alternative boundary="EachEmailAlternative"rn". $goodAttachment = chunk_split(base64_encode(file_get_contents( "novyrus.zip"))) $subject = "Please donate all your moneys to us" Now, let’s check out a full-blown multipart mail() example that has an HTML body with a plain text alternative and a file attachment: rn". Because that’s all beyond the scope of this article, I’ll assume you’re set. ![]() In either case, there are plenty of resources available online to help you out. ![]() You’ll really only need to worry about extra configuration if you’re compiling PHP from source or if you’re running it on Windows. If you are using a shared host, or if you installed PHP using a package management system like apt-get, more than likely you’re all set. In most cases your installation of PHP will be capable of sending emails. Well, maybe you have a cron job that you want to inform you of issues, have a user-initiated script you’d like to be notified when run, have a “Contact Us” form that forwards messages to you, want to flex your PHP muscles and write your own web-based mail client, need to set up a confirmation-by-email script – there are plenty of other reasons to send email with PHP. There’s so much more you could be doing with your life! But, what other reasons could you possibly have? I’m here to tell you you’re better than that. We know why you’re here… you want to write a script to send emails to your friends with funny return addresses. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |