URGENT: PHP mail() solution : PEAR Mailer - Completion time 1 hour today

Job ID: 32375504

Budget: £10 – £20 GBP

I'm looking for someone who has setup PEAR Mailer and can help to set up within an hour.

I want someone who can talk me through setting this up to send an email. I can handle everything after that.



https://mailtrap.io/blog/php-email-sending/




require_once './vendor/autoload.php';
$from = 'Your Hotel <email>';
$to = 'Me <email>';
$subject = 'Thanks for choosing Our Hotel!';

$headers = ['From' => $from,'To' => $to, 'Subject' => $subject];

// include text and HTML versions
$text = 'Hi there, we are happy to confirm your booking. Please check the document in the attachment.';
$html = 'Hi there, we are happy to <br>confirm your booking.</br> Please check the document in the attachment.';

//add attachment
$file = '/confirmations/yourbooking.pdf';

$mime = new Mail_mime();
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');

$body = $mime->get();
$headers = $mime->headers($headers);

$host = 'smtp.mailtrap.io';
$username = '1a2b3c4g5f6g7e'; // generated by Mailtrap
$password = '1a2b3c4g5f6g7e'; // generated by Mailtrap
$port = '2525';

$smtp = Mail::factory('smtp', [
'host' => $host,
'auth' => true,
'username' => $username,
'password' => $password,
'port' => $port
]);

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
Related categories: PHP Email Handling Email Developer Direct Mail