Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 30100

Sending an email in php - swiftmailer

$
0
0

I've been searching for days if not weeks on how to automatically send a simple e-mail in php after a user completes my form. I've tried Pear, PHP mail, Swiftmailer, changed my php.ini, tried different servers and I'm going mad from none of it working. I have not successfully sent one e-mail yet. I've searched endlessly but I still have no idea what to do and why nothing is working. At the moment I'm using Swiftmailer (second time round). I set up a test page with code:

<?php
require_once 'swift/lib/swift_required.php';


// CREATE TRANSPORT CONFIG
$transport = Swift_MailTransport::newInstance();


// CREATE MSG
$message = Swift_Message::newInstance();

// SET PRIORITY TO HIGH
$message->setPriority(2);

// SUBJECT
$message->setSubject('Subject');

// FROM
$message->setFrom(array('example@btopenworld.com'));

// TO
$message->setTo(array('example@googlemail.com'));

// EMAIL BODY
$message->setBody('Test');

// SEND
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);

if (!$mailer->send($message, $failures)) {
echo "Failures:";
print_r($failures);
}


?>

Looking at a similar post someone suggested the last part of the code to see errors and my error is:

Failures:Array ( [0] => example@googlemail.com )

No matter what e-mail I change it to (all using e-mails I have, so real e-mails) it doesn't work. If anyone has any help or suggestions it would be hugely appreciated.


Viewing all articles
Browse latest Browse all 30100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>