Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP error when trying to send email using Swift Mailer
    primarykey
    data
    text
    <p>I ve tried everything, i don't know how to fix this, so, i am using this Swift Mailer library to send a confirmation email. So here is the code from my index.php</p> <pre><code>if($confirm){ //include the swift class include_once 'inc/php/swift/swift_required.php'; //put info into an array to send to the function $info = array( 'username' =&gt; $username, 'email' =&gt; $email, 'key' =&gt; $key); //send the email if(send_email($info)){ //email sent $action['result'] = 'success'; array_push($text,'Thanks for signing up. Please check your email for confirmation!'); }else{ $action['result'] = 'error'; array_push($text,'Could not send confirm email'); } } </code></pre> <p>And my send_email function is in another php file functions.php</p> <pre><code>//send the welcome letter function send_email($info){ //format each email $body = format_email($info,'html'); $body_plain_txt = format_email($info,'txt'); //setup the mailer $transport = Swift_MailTransport::newInstance(smtp.gmail.com,465,ssl) -&gt;setUsername('my email here') -&gt;setPassword('my password'); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance(); $message -&gt;setSubject('Welcome to Site Name'); $message -&gt;setFrom(array('somedomain.com' =&gt; 'somethinghere')); $message -&gt;setTo(array($info['email'] =&gt; $info['username'])); $message -&gt;setBody($body_plain_txt); $message -&gt;addPart($body, 'text/html'); $result = $mailer-&gt;send($message); return $result; } </code></pre> <p>The error that i am getting is</p> <blockquote> <p>Fatal error: Call to undefined method Swift_MailTransport::setUsername() in /srv/disk7/something/www/something/signup/inc/php/functions.php on line 31</p> </blockquote> <p>How can i fix this? I am a beginner in php.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload