Ejemplo n.º 1
0
 /**
  * Sends the email.
  * @param string $format allowed values are 'html', 'plain' or 'both'
  * @return boolean true on success, false otherwise
  */
 public function send($format = 'plain')
 {
     $headers = $this->get_headers($format);
     $sent_date = awpcp_format_email_sent_datetime();
     $body = sprintf("%s\n\n%s", $this->body, $sent_date);
     if ($result = wp_mail($this->to, $this->subject, $body, $headers)) {
         return $result;
     }
     if ($result = awpcp_send_email($this->from, $this->to, $this->subject, $body, $format === 'html')) {
         return $result;
     }
     if ($result = @mail($this->to, $this->subject, $body, $headers)) {
         return $result;
     }
     return false;
 }
Ejemplo n.º 2
0
function awpcp_process_mail($senderemail = '', $receiveremail = '', $subject = '', $body = '', $sendername = '', $replytoemail = '', $html = false)
{
    $headers = "MIME-Version: 1.0\n" . "From: {$sendername} <{$senderemail}>\n" . "Reply-To: {$replytoemail}\n";
    if ($html) {
        $headers .= "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
    } else {
        $headers .= "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    }
    $subject = $subject;
    $message = "{$body}\n\n" . awpcp_format_email_sent_datetime() . "\n\n";
    _log("Processing email");
    if (wp_mail($receiveremail, $subject, $message, $headers)) {
        _log("Sent via WP");
        return 1;
    } elseif (awpcp_send_email($senderemail, $receiveremail, $subject, $body, true)) {
        _log("Sent via send_email");
        return 1;
    } elseif (@mail($receiveremail, $subject, $body, $headers)) {
        _log("Sent via mail");
        return 1;
    } else {
        _log("SMTP not configured properly, all attempts failed");
        return 0;
    }
}