Link to home
Start Free TrialLog in
Avatar of Yashy
YashyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

What is the location of the file for instructing PHP to include 'multipart' in emails? Is it PHP mailer? I'm looking for it, don't know where to look

hi guys,

We have a Amazon Linux server, which is using Postfix to send the emails. We need to go in and make a change to the PHP mailer (i believe?) in order for it to include 'multipart' when emails are sent out.

Do you know where I need to look and what the name of the file should be that needs to opened and have the multipart code added to it?

Cheers
Yashy
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Please post the code you are using to create your emails.

The multipart is setup as part of creating your email message - when you create your email you specify the multipart sections - but to do it from scratch is a pain - better to use something like PHPMailer (https://github.com/PHPMailer/PHPMailer) and let it do the hard work.

Which is why to answer your question - we need to know how you are creating your emails.
Avatar of Yashy

ASKER

Hi Julian,

We're basically calling this function in PHP:

<?php
 
if(isset($_GET['email']))
{
error_reporting(E_ALL); ini_set('display_errors', '1');
 
        $email = $_GET['email'];
 
$subject = 'Email Subject';
                               
//create a boundary for the email. This
$boundary = uniqid('np');
                               
//headers - specify your from email address and name here
//and specify the boundary for the email
$headers = 'From: Contoso <no-reply@Contoso.com>' . "\r\n" .
   'Reply-To: Contoso <contact@Contoso.com>' . "\r\n";
 $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
 
//here is the content body
$message = "\r\n\r\n--" . $boundary . "\r";
$message .= "Content-type: text/plain;charset=utf-8\rContent-Transfer-Encoding: 7bit\r\n\r\n";
 
//Plain text body
$message .= "Hello,\nThis is a text email, the text/plain version.
\n\nRegards,\nYour Name";
$message .= "\r\n\r\n--" . $boundary . "\r";
$message .= "Content-Type: text/html; charset=utf-8\rContent-Transfer-Encoding: quoted-printable\r\n\r\n";
 
//Html body
$message .= file_get_contents('test.php');
$message .= "\r\n\r\n--" . $boundary . "--";
 
 
//invoke the PHP mail function
mail($email, $subject, $message, $headers);
       
       
       
}
?>

Open in new window


However, our developer (codes in PHP) says that he didn't even think we're using phpMailer.  Nowhere in our code is there anything that calls the phpMailer function.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yashy

ASKER

Thank you Julian. I haven't explained everything. We're using the Amazon SES service at the moment (something I'm slowly regretting).

But I appreciate your help on this.
I haven't explained everything. We're using the Amazon SES service at the moment
Either way you should be able to use PHPMailer - if you have you cannot use an external service - although the latter should not be predicated on who you host with - but as you say you have not given all the details so maybe I am missing something.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And PHPMailer is a good suggestion also.