/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Swiftmailer Error Message

I am using the below script to validate and send attachment with swiftmailer.

[code=php]<?php

session_start();

/* check_input code to validate some field */

/* some regex to validate email, text only, etc */

if (!empty($_FILES[“photo”])) {

foreach ($_FILES[“photo”][“tmp_name”] as $key => $value) {

if (!$_FILES[“photo”][“error”][$key]) {

$message->attach(Swift_Attachment::newInstance(($value), $_FILES[“photo”][“name”][$key], $_FILES[“photo”][“type”][$key]))
->attach(Swift_Attachment::newInstance(($value), $_FILES[“photo”][“name”][$key], $_FILES[“photo”][“type”][$key]))
->attach(Swift_Attachment::newInstance(($value), $_FILES[“photo”][“name”][$key], $_FILES[“photo”][“type”][$key]))
->attach(Swift_Attachment::newInstance(($value), $_FILES[“photo”][“name”][$key], $_FILES[“photo”][“type”][$key]));

} }}
require_once ‘../lib/swift_required.php’;

$transport = Swift_MailTransport::newInstance();

$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance()
->setSubject(array(‘Submitted Photo’))
->setFrom(array($email => $name))
->setTo(array(‘[email protected]’ => ‘A name’))
->setBody($html, ‘text/html’)

$result = $mailer->send($message);

function check_input($data, $problem=”)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}

function show_error($Error)
{}
?>[/code]

I am getting the below message. Please help.

[QUOTE]

Warning: preg_split() expects parameter 2 to be string, array given in lib/classes/Swift/Mime/Headers/AbstractHeader.php on line 340

Warning: Invalid argument supplied for foreach() in lib/classes/Swift/Mime/Headers/AbstractHeader.php on line 340

[/QUOTE]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @carygh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...