5

emailcrypto

emailcrypto
SYNOPSIS

emailcrypto($text, $tag, $to, $subject, $sender)

DESCRIPTION

emailcrypto sends the message $text with an attached cryptogram of $tag to $to with the subject $subject from $sender.

$tag is a short string of characters, typically a password.

CODE
  1. require_once 'strtag.php';

Loads the function strtag.

  1. function emailcrypto($text, $tag, $to, $subject, $sender=false) {
  2.     global $signature, $mailer, $webmaster;
  3.  
  4.     if (!$sender) {
  5.         $sender = $webmaster;
  6.     }

emailcrypto has 4 or 5 arguments : a message, a short text to be joined to the message in a crytogram, the email address of the recipient of the message, the email address of the sender of the message.

If the argument $sender is false, it's initialized to the value of $webmaster

The global variables $signature, $mailer and $webmaster are configuration parameters defined in the file includes/config.inc.

  1.     $img=strtag($tag);
  2.  
  3.     ob_start();
  4.     imagepng($img);
  5.     imagedestroy($img);
  6.     $imgdata=ob_get_contents();
  7.     ob_end_clean();
  8.  
  9.     $sep=md5(uniqid('sep'));
  10.     $data=chunk_split(base64_encode($imgdata));

Builds a cryptogram from the string of characters $tag with strtag then converts the obtained image in PNG. The PNG is then encoded in base64.

  1.     $headers = <<<_SEP_
  2. From: $sender
  3. Return-Path: $sender
  4. Content-Type: multipart/mixed; boundary="$sep"
  5. X-Mailer: $mailer
  6. _SEP_;

Generates the MIME header of the email with the fields From:, Return-Path:, Content-Type: and X-Mailer: with the parameter $sender and the glocal variable $mailer. The field Content-Type: indicates that the message is in 2 parts, the text of email and the attached cryptogram, separated by $sep.

  1.     $body = '';
  2.  
  3.     if ($text) {
  4.         $body .= <<<_SEP_
  5. --$sep
  6. Content-Type: text/plain; charset=utf-8
  7.  
  8. $text
  9.  
  10. $signature
  11.  
  12. _SEP_;
  13.     }
  14.  
  15.     $body .= <<<_SEP_
  16. --$sep
  17. Content-Type: image/png; name="crypto.png"
  18. Content-Transfer-Encoding: base64
  19. Content-Disposition: inline; filename="crypto.png"
  20.  
  21. $data
  22. --$sep--
  23. _SEP_;
  24.  
  25.     return @mail($to, $subject, $body, $headers);
  26. }

Builds the body of the email, first the text followed by the attached image, then sends the email with the PHP function mail.

SEE ALSO

strtag, emailhtml, emailme, emailtext

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

===

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].