Esempio n. 1
0
function sendEmail($contactForm)
{
    // Email part will create the email information needed to send an email based on
    // what was inserted inside the contact form
    $emailParts = new EmailParts($contactForm);
    // This is the part where we initialize Swiftmailer with
    // all the info initialized by the EmailParts class
    $emailMessage = Swift_Message::newInstance()->setSubject($emailParts->getSubject())->setFrom($emailParts->getFrom())->setTo($emailParts->getTo())->setBody($emailParts->getBodyMessage());
    // If an attachment was included, add it to the email
    if ($contactForm->hasAttachment()) {
        $attachmentPath = $contactForm->getAttachmentPath();
        $emailMessage->attach(Swift_Attachment::fromPath($attachmentPath));
    }
    // Another Swiftmailer configuration. You can change SMTP mode to Mail, Sendmail, etc.
    // see http://swiftmailer.org/docs/sending.html for more details
    $transport = Swift_SmtpTransport::newInstance(SMTP_SERVER, SMTP_PORT);
    $mailer = Swift_Mailer::newInstance($transport);
    $result = $mailer->send($emailMessage);
    return $result;
}
Esempio n. 2
0
function sendEmail($contactForm)
{
    // Email part will create the email information needed to send an email based on
    //echo ("111111111111111111111");
    // what was inserted inside the contact form
    //var_dump($contactForm);
    $emailParts = new EmailParts($contactForm);
    // echo ("2222222222222222");
    // This is the part where we initialize Swiftmailer with
    // all the info initialized by the EmailParts class
    $emailMessage = Swift_Message::newInstance()->setSubject($emailParts->getSubject())->setFrom($emailParts->getFrom())->setTo($emailParts->getTo())->setBody($emailParts->getBodyMessage());
    //echo ("33333333333333333");
    // If an attachment was included, add it to the email
    if ($contactForm->hasAttachment()) {
        //echo ("00000000000000000000000000");
        $attachmentPath = $contactForm->getAttachmentPath();
        $emailMessage->attach(Swift_Attachment::fromPath($attachmentPath));
    }
    // Another Swiftmailer configuration. You can change SMTP mode to Mail, Sendmail, etc.
    // see http://swiftmailer.org/docs/sending.html for more details
    $transport = Swift_SmtpTransport::newInstance('ssl://smtp.gmail.com', 465)->setUsername('*****@*****.**')->setPassword('imiae123456789azerty');
    //echo ("4444444444444444444444444444");
    $mailer = Swift_Mailer::newInstance($transport);
    // var_dump($mailer);
    // echo ("55555555555555555555");
    $result = $mailer->send($emailMessage);
    // var_dump($result);
    // echo ("6666666666666666666");
    return $result;
}