Hemos venido utilizando desde hace muchos años el modulo PHPMimeMail para el envio de correos en PHP, es una clase que funciona muy bien y estaba muy implementado.
El problema es que se está quedando obsoleta. El mismo creador, ha creado RMail, otro modulo de envio que funciona para PHP5 y que hemos comprobado con nuestros desarrollos web, que mejora en un 70% los tiempos de envio.
El proceso de actualización es muy sencillo ya que los metodos utilizados en ambos módulos son similares.
Method | Description |
---|---|
Constructor | Doesn’t take any arguments. Not much to say I guess. |
setCRLF(string $crlf) | Sets the CRLF line ending type to use. You should not use this unless you’re sure you know what you’re doing, as the code will correctly (most of the time) determine which type to use by itself. |
setSMTPParams(string $host, int $port, string $helo, bool $auth, string $user, string $pass) |
Set SMTP parameters when using SMTP to send the email. All optional, though not specifying any would be pointless… Pretty self explanatory really – hostname to connect to, port to connect to, text to send as part of the HELO command, whether to use SMTP authentication, and if so the username and password to use. |
setSendmailPath(string $path) | Sets the path to use when using sendmail method of sending the email. This should be the full path to the sendmail binary on your system, along with any command line parameters. Defaults to «/usr/lib/sendmail -ti». |
setTextEncoding(object $encoding) | Sets the encoding to use (if any) on the plain text part of the email. The argument should be one of the encoding objects, ie Base64Encoding, QPrintEncoding, SevenBitEncoding or EightBitEncoding. Bit pants about the 7bit/8bit names, but identifiers in PHP can’t start with a number. Tits. |
setHTMLEncoding(object $encoding) | Sets the encoding to use (if any) on the HTML part of the email. The argument should be one of the encoding objects, ie Base64Encoding, QPrintEncoding, SevenBitEncoding or EightBitEncoding. |
setTextCharset(string $charset) | Sets the characterset to use on the plain text portion of the email. Defaults to «ISO-8859-1». |
setHTMLCharset(string $charset) | Sets the characterset to use on the plain text portion of the email. Defaults to «ISO-8859-1». |
setHeadCharset(string $charset) | Sets the characterset to use on the headers of the email. Defaults to «ISO-8859-1». |
setTextWrap(int $count) | Set the point at which text is wrapped in the email. Defaults to 998, which is a limit imposed by the SMTP standard. |
setHeader(string $name, string $value) | Sets a header of the email. First argument if the name of the email, second is the value. |
setSubject(string $subject) | Sets the subject of the email. |
setFrom(string $from) | Sets the From: header of the email. |
setPriority(mixed $priority) | Sets the priority of the email. Defaults to «normal». Argument can be either «high», «normal» or «low», or 1, 3 or 5 respectively. |
setReturnPath(string $return_path) | Sets the Return-Path: of the email. This is the address to which bounces will be sent if the email fails to be delivered. |
setCc(string $cc) | Sets the Cc: header of the email. The email will be delivered to these addresses as well as those specified in the send() method. |
setBcc(string $bcc) | Sets the Bcc: header of the email. The email will be delivered to these addresses as well as those specified in the send() method. However, the Bcc: header will be removed from email before it is sent, so those addresses in the To: and Cc: headers will not know it has also been sent to these addresses. Hence, «Blind» Carbon Copy. |
setText(string $text) | Sets the text part of the email. |
setHTML(string $html[, string $images_dir]) | Sets the HTML part of the email. The optional second argument specifies a directory where the code should look for images referenced by the HTML. If found, these images will automatically be embedded into the email. |
addEmbeddedImage(object $embeddedImage) | Adds an embeddded image to the email. The argument should be on of the fileEmbeddedImage or stringEmbeddedImage objects, depending on the source of the image. |
addAttachment(object $attachment) | Adds an attachment to the email. The argument should be one of the fileAttachment or stringAttachment objects, depending on the source of the attachment. |
send(array $recipients[, string $type]) | Sends the email. The first argument is an array of recipients to whom the email will be sent to. The second is how to send the email. This can be one of «mail», «sendmail» or «smtp», and defaults to «mail». |
getRFC822(array $recipients[, string $type]) | This function first of all builds the email, and then returns it in text format. This is useful if you need to attach the email to another email. This could be done like so: $mail_2->addAttachment(new stringAttachment($mail_1->getRFC822(array(‘[email protected]’)), ‘message/rfc822’)) The first argument is an array of recipients to place in the To: header, whilst the second, optional, $type argument should be the same as that you intend to use eventually for the send() method. This is to ensure the correct line endings are used. |