Title: PHP to Send Mail
Last modified: May 24, 2018

---

# PHP to Send Mail

 *  Resolved [lawrence-pepper](https://wordpress.org/support/users/lawrence-pepper/)
 * (@lawrence-pepper)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-to-send-mail/)
 * Hello,
 * I have Mail Blank setup properly to send mail through our Office 365 account.
   It send the test mails out fine. But none of my emails from my PHP code is being
   sent.
 * The code being used:
 * // mail to
    $to = $superemail;
 * // subject
    $subject = ‘Hours Submitted for Approval’;
 * // message
    $message = ‘ <html> <body> ‘ . $super . ‘,<br> <br> ‘ . $person .‘
   has requested you review his/her hours that have been submitted for approval 
   in the time sheets application. <br><br> <b>Comments:</b><br> ‘ . $comment . ‘
   <br> <br> Please follow this link to approve all submitted hours for ‘ . $person.‘:
   <br> <br> [Approve Hours](http://XXX) <br><br> Thanks, <br><br> <b>Your Friendly
   Neighborhood Time Sheets Program</b>
 * </body>
    </html> ‘;
 * // To send HTML mail, the Content-type header must be set
    $headers = ‘MIME-Version:
   1.0’ . “\r\n”; $headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\
   r\n”;
 * // Additional headers
    $headers .= ‘From: ‘ . $person . ‘ <‘ . $useremail . ‘
   >’ . “\r\n”;
 * // Mail it
 * mail($to, $subject, $message, $headers);`
 * What am I doing wrong? Thank you for any help!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Varun Sharma](https://wordpress.org/support/users/contact-banker/)
 * (@contact-banker)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-to-send-mail/#post-10334379)
 * Hi,
 * We only support wp_mail function and override it with our custom settings.
 * So, we recommend it using the wp_mail function instead of mail function, so Mail
   Bank can bypass it and use the SMTP Settings to send emails.
 * Thanks
 *  Thread Starter [lawrence-pepper](https://wordpress.org/support/users/lawrence-pepper/)
 * (@lawrence-pepper)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-to-send-mail/#post-10335971)
 * Hello – I tried using the wp_mail function and it does not work. Your test email
   never gets sent.
 * I get the following:
 * 2018-05-29 12:46:35 Could not instantiate mail function.
    Your Web Host provider
   may have blocked the use of mail() function on your server. Ask them to enable
   the mail() function to start sending emails.
 * When I use the mail function it does get sent but my code above does not work.
 *  Thread Starter [lawrence-pepper](https://wordpress.org/support/users/lawrence-pepper/)
 * (@lawrence-pepper)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-to-send-mail/#post-10335980)
 * Message when testing using SMTP Option:
 * Checking your settings
    Sending Test Email to lpepper@xxxxxxxxx Email Status :
   Email Sent —————————————————————————————- Debug Output : —————————————————————————————-
   220 BN4PR12CA0011.outlook.office365.com Microsoft ESMTP MAIL Service ready at
   Tue, 29 May 2018 12:48:28 +0000 EHLO localhost 250-BN4PR12CA0011.outlook.office365.
   com Hello [96.245.114.250] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES
   250-STARTTLS 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 STARTTLS 220
   2.0.0 SMTP server ready EHLO localhost 250-BN4PR12CA0011.outlook.office365.com
   Hello [96.245.114.250] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES
   250-AUTH LOGIN XOAUTH2 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 
   AUTH LOGIN 334 VXNlcm5hbWU6 bHBlcHBlckBnZW4tdGVjaG5vLmNvbQ== 334 UGFzc3dvcmQ6
   TWVsbG9uMjAxNg== 235 2.7.0 Authentication successful target host SN1PR20MB2192.
   namprd20.prod.outlook.com MAIL FROM:<lpepper@xxxxxxxx> 250 2.1.0 Sender OK RCPT
   TO:<lpepper@xxxxxxxx> 250 2.1.5 Recipient OK DATA 354 Start mail input; end with
   <CRLF>.<CRLF> To: lpepper@xxxxxx From: lpepper@gxxxxxxxxx Subject: Test Email–
   Mail Bank X-Mailer: Mail Bank SMTP 3.0.61 for WordPress ([https://wordpress.org/plugins/wp-mail-bank/](https://wordpress.org/plugins/wp-mail-bank/))
   Content-Type: text/html; charset=utf-8 Date: Tue, 29 May 2018 12:48:29 +0000 
   Content-Transfer-Encoding: quoted-printable Content-Disposition: inline MIME-
   Version: 1.0
 * This is a demo Test Email for Email Setup – Mail Bank
    . 250 2.6.0 <SN1PR20MB2192CF4B1828AC9AAEA8F6DA816D0@SN1PR20MB2192.
   namprd20.prod.outlook.com> [InternalId=8963596752490, Hostname=SN1PR20MB2192.
   namprd20.prod.outlook.com] 3325 bytes in 0.294, 11.029 KB/sec Queued mail for
   delivery
 * Yet my code does not work above…..
 * Any ideas?
    -  This reply was modified 7 years, 11 months ago by [lawrence-pepper](https://wordpress.org/support/users/lawrence-pepper/).
    -  This reply was modified 7 years, 11 months ago by [lawrence-pepper](https://wordpress.org/support/users/lawrence-pepper/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP to Send Mail’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-mail-bank_724f4f.svg)
 * [Mail Bank - #1 Mail SMTP Plugin for WordPress](https://wordpress.org/plugins/wp-mail-bank/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-bank/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-bank/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-bank/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-bank/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-bank/reviews/)

## Tags

 * [mail](https://wordpress.org/support/topic-tag/mail/)

 * 3 replies
 * 2 participants
 * Last reply from: [lawrence-pepper](https://wordpress.org/support/users/lawrence-pepper/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/php-to-send-mail/#post-10335980)
 * Status: resolved